@zktx.io/sui-mcp 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/README.md +83 -42
  2. package/dist/core/activity/localDataService.js +8 -21
  3. package/dist/core/activity/localDataValidation.js +22 -46
  4. package/dist/core/activity/sqliteAccountStore.js +46 -0
  5. package/dist/core/activity/sqliteActivityStore.js +65 -147
  6. package/dist/core/activity/sqliteActivityStoreSchema.js +42 -26
  7. package/dist/core/activity/transactionActivityService.js +2 -2
  8. package/dist/core/preferences/preferencesStore.js +2 -2
  9. package/dist/core/preferences/sqlitePreferencesRepository.js +10 -0
  10. package/dist/core/session/cardResult.js +41 -0
  11. package/dist/core/session/cardSession.js +1 -1
  12. package/dist/core/session/cardSessionStore.js +51 -19
  13. package/dist/core/session/chainAccounts.js +120 -0
  14. package/dist/core/session/sessionStore.js +4 -8
  15. package/dist/core/session/settingsFileStore.js +3 -30
  16. package/dist/core/session/settingsOperation.js +27 -19
  17. package/dist/core/session/settingsWorkflow.js +161 -87
  18. package/dist/core/session/sqliteCardStore.js +34 -14
  19. package/dist/core/session/sqliteSessionStore.js +5 -5
  20. package/dist/core/session/sqliteSettingsWorkflowStore.js +135 -41
  21. package/dist/core/session/sqliteTransactionRequest.js +18 -0
  22. package/dist/core/session/sqliteWalletConnectionOperation.js +13 -0
  23. package/dist/core/session/sqliteWalletWorkflowStore.js +569 -333
  24. package/dist/core/session/status.js +2 -2
  25. package/dist/core/session/wait.js +6 -11
  26. package/dist/core/session/walletConnection.js +71 -46
  27. package/dist/core/session/walletConnectionOperations.js +24 -0
  28. package/dist/core/session/walletRuntime.js +7 -13
  29. package/dist/core/session/walletWorkflow.js +248 -99
  30. package/dist/core/session/workflowState.js +104 -38
  31. package/dist/core/session/workflowView.js +92 -101
  32. package/dist/mcp/activeAccountResponse.js +3 -0
  33. package/dist/mcp/responseGuidance.js +7 -9
  34. package/dist/mcp/serverInfo.js +11 -10
  35. package/dist/mcp/toolErrors.js +5 -3
  36. package/dist/mcp/toolNames.js +1 -0
  37. package/dist/mcp/tools/action/prepareSuiActionReview.js +9 -16
  38. package/dist/mcp/tools/read/readToolHelpers.js +9 -7
  39. package/dist/mcp/tools/session/executionResultTools.js +2 -2
  40. package/dist/mcp/tools/session/shared.js +2 -2
  41. package/dist/mcp/tools/session/statusTools.js +12 -10
  42. package/dist/mcp/tools/session/walletConnectionTools.js +26 -14
  43. package/dist/mcp/tools/settings/index.js +7 -4
  44. package/dist/mcp-app/account.html +7 -7
  45. package/dist/mcp-app/chart.html +3 -3
  46. package/dist/mcp-app/connect.html +13 -13
  47. package/dist/mcp-app/disconnect.html +3637 -0
  48. package/dist/mcp-app/disconnect.notices.txt +1480 -0
  49. package/dist/mcp-app/receipt.html +393 -393
  50. package/dist/mcp-app/review.html +459 -459
  51. package/dist/mcp-app/settings.html +7 -7
  52. package/dist/mcp-ui/contracts.js +3 -1
  53. package/dist/mcp-ui/tools.js +4 -4
  54. package/dist/runtime/application.js +1 -1
  55. package/dist/runtime/localSettingsService.js +7 -4
  56. package/dist/runtime/smokeMainnetRead.js +5 -4
  57. package/dist/runtime/walletConnectTransport.js +16 -16
  58. package/dist/runtime/walletSdkChildRuntime.js +29 -12
  59. package/dist/runtime/walletSdkIpc.js +5 -4
  60. package/dist/runtime/walletSdkProcess.js +24 -8
  61. package/docs/AGENT_BEHAVIOR.md +82 -54
  62. package/docs/LOCAL_DB_ARCHITECTURE.md +100 -70
  63. package/docs/MCP_SETUP.md +319 -339
  64. package/docs/MCP_TOOLS.md +292 -177
  65. package/docs/SDK_API.md +15 -6
  66. package/docs/TRANSACTION_ACTIVITY_LOG.md +4 -0
  67. package/docs/UTILITY_INDEX.md +9 -7
  68. package/docs/WALLET_CONNECTION.md +162 -167
  69. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- <!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Sui MCP</title><style>:root[data-theme=light]{--ui-bg:#f6f8fa;--ui-surface:#fff;--ui-surface-2:#eef1f5;--ui-border:#e3e8ef;--ui-border-strong:#cdd5e0;--ui-text:#18202b;--ui-text-muted:#5b6675;--ui-accent:#1565c0;--ui-accent-hover:#0d47a1;--ui-on-accent:#fff;--ui-focus:#1565c040;--ui-ok-bg:#e2f3e9;--ui-ok-text:#1b6b43;--ui-warn-bg:#fbeeda;--ui-warn-text:#8a5a08;--ui-danger:#b3261e;--ui-danger-bg:#fbe9e7;--ui-up:#1b7f43;--ui-down:#b3261e}:root[data-theme=dark]{--ui-bg:#0e141b;--ui-surface:#161d26;--ui-surface-2:#1e2733;--ui-border:#28323f;--ui-border-strong:#3a4859;--ui-text:#e7edf4;--ui-text-muted:#9aa7b6;--ui-accent:#4da2ff;--ui-accent-hover:#6fb8ff;--ui-on-accent:#06243f;--ui-focus:#4da2ff52;--ui-ok-bg:#10362a;--ui-ok-text:#7fe0b0;--ui-warn-bg:#3a2e16;--ui-warn-text:#f0c97a;--ui-danger:#ff8a80;--ui-danger-bg:#3a1f1d;--ui-up:#46c79e;--ui-down:#ff8a80}:root{--ui-r:10px;--ui-font-sans:ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;--ui-font-mono:ui-monospace, SFMono-Regular, Menlo, monospace}*,:before,:after{box-sizing:border-box}body{background:var(--ui-bg);color:var(--ui-text);font-family:var(--ui-font-sans);-webkit-font-smoothing:antialiased;margin:0;font-weight:400}.ui-mono{font-family:var(--ui-font-mono);overflow-wrap:anywhere;font-size:12.5px}.ui-btn{border:.5px solid var(--ui-border-strong);border-radius:var(--ui-r);background:var(--ui-surface);min-height:38px;color:var(--ui-text);font:inherit;cursor:pointer;justify-content:center;align-items:center;gap:7px;padding:0 16px;font-size:14px;font-weight:500;transition:background .12s,border-color .12s,transform 60ms;display:inline-flex}.ui-btn:hover{background:var(--ui-surface-2);border-color:var(--ui-accent)}.ui-btn:active{transform:scale(.975)}.ui-btn:focus-visible{box-shadow:0 0 0 3px var(--ui-focus);outline:none}.ui-btn--primary{background:var(--ui-accent);border-color:var(--ui-accent);color:var(--ui-on-accent)}.ui-btn--primary:hover{background:var(--ui-accent-hover);border-color:var(--ui-accent-hover)}.ui-btn--danger{border-color:var(--ui-danger);color:var(--ui-danger)}.ui-btn--danger:hover{background:var(--ui-danger-bg)}.ui-btn:disabled{cursor:not-allowed;color:var(--ui-text-muted);background:var(--ui-surface-2);border-color:var(--ui-border)}.ui-btn-row{flex-wrap:wrap;gap:10px;margin-top:12px;display:flex}.ui-btn-row>.ui-btn{flex:1 1 0;min-width:12rem}.ui-btn-row--end{justify-content:flex-end}.ui-btn-row--end>.ui-btn{flex:none;min-width:0}.ui-icon-btn{border:.5px solid var(--ui-border-strong);background:var(--ui-surface);width:34px;height:34px;color:var(--ui-text);cursor:pointer;border-radius:9px;flex:none;justify-content:center;align-items:center;padding:0;transition:background .12s,border-color .12s,transform 60ms;display:inline-flex}.ui-icon-btn:hover{background:var(--ui-surface-2);border-color:var(--ui-accent)}.ui-icon-btn:active{transform:scale(.94)}.ui-icon-btn:focus-visible{box-shadow:0 0 0 3px var(--ui-focus);outline:none}.ui-icon-btn svg{width:18px;height:18px}.ui-link{color:var(--ui-accent);cursor:pointer;text-decoration:none}.ui-link:hover{color:var(--ui-accent-hover);text-decoration:underline}.ui-field{color:var(--ui-text-muted);flex-direction:column;gap:5px;font-size:12px;display:flex}.ui-input,input.ui-input{border:.5px solid var(--ui-border-strong);border-radius:var(--ui-r);background:var(--ui-surface);height:38px;color:var(--ui-text);font:inherit;outline:none;padding:0 12px;font-size:14px;transition:border-color .12s,box-shadow .12s}.ui-input{width:100%}.ui-input::placeholder{color:var(--ui-text-muted)}.ui-select{border:.5px solid var(--ui-border-strong);border-radius:var(--ui-r);background:var(--ui-surface);width:100%;height:38px;color:var(--ui-text);font:inherit;cursor:pointer;outline:none;padding:0 12px;font-size:14px;transition:border-color .12s,box-shadow .12s}.ui-select:focus,.ui-input:focus{border-color:var(--ui-accent);box-shadow:0 0 0 3px var(--ui-focus)}.ui-card{background:var(--ui-surface);border:.5px solid var(--ui-border);padding:var(--ui-card-padding-block,16px) var(--ui-card-padding-inline,18px);border-radius:12px;margin:0 0 14px}.ui-section{min-width:0;margin-block:0 16px}.ui-section-title{justify-content:space-between;align-items:center;gap:10px;margin:0 0 10px;font-size:14px;font-weight:500;display:flex}.ui-card-title{margin:0 0 10px;font-size:14px;font-weight:500}.ui-card-head{margin:calc(-1 * var(--ui-card-padding-block,16px)) calc(-1 * var(--ui-card-padding-inline,18px)) 14px;padding:9px var(--ui-card-padding-inline,18px);background:var(--ui-surface-2);border-bottom:.5px solid var(--ui-border);border-radius:12px 12px 0 0;justify-content:space-between;align-items:center;gap:10px;font-size:14px;font-weight:500;display:flex}.ui-card-head+.ui-detail-item,.ui-card-head+.ui-row{border-top:0}.ui-row{border-top:.5px solid var(--ui-border);grid-template-columns:minmax(140px,.34fr) minmax(0,1fr);gap:12px;padding:9px 0;font-size:14px;display:grid}.ui-row:first-child{border-top:0}.ui-row-label{color:var(--ui-text-muted)}.ui-row-value{color:var(--ui-text);overflow-wrap:anywhere;font-variant-numeric:tabular-nums;text-align:right}.ui-status-banner{border-radius:var(--ui-r);border:.5px solid var(--ui-border-strong);background:var(--ui-surface-2);color:var(--ui-text);align-items:center;gap:9px;padding:11px 0;font-size:14px;font-weight:500;display:flex}.ui-status-icon{flex:none;display:inline-flex}.ui-status-icon svg{width:18px;height:18px}.ui-status-banner--success{background:var(--ui-ok-bg);color:var(--ui-ok-text);border-color:#0000}.ui-status-banner--failure{background:var(--ui-danger-bg);color:var(--ui-danger);border-color:#0000}.ui-status-banner--pending{color:var(--ui-text-muted)}.ui-detail-item{border-top:.5px solid var(--ui-border);padding:9px 0}.ui-detail-head{flex-wrap:wrap;justify-content:space-between;align-items:baseline;gap:12px;display:flex}.ui-detail-title{color:var(--ui-text);overflow-wrap:anywhere;font-weight:500}.ui-detail-trailing{color:var(--ui-text);overflow-wrap:anywhere}.ui-detail-trailing--up{color:var(--ui-up)}.ui-detail-trailing--down{color:var(--ui-down)}.ui-detail-meta{color:var(--ui-text-muted);overflow-wrap:anywhere;gap:8px;margin-top:3px;font-size:12.5px;display:flex}.ui-detail-metalabel{color:var(--ui-text-muted);flex:none}.ui-feedback{border:.5px solid var(--ui-border);background:var(--ui-surface);color:var(--ui-text);border-left-width:3px;border-radius:8px;margin:0 0 14px;padding:11px 13px;font-size:13.5px}.ui-feedback--ok{border-left-color:var(--ui-ok-text)}.ui-feedback--error{border-left-color:var(--ui-danger)}.ui-card>.ui-feedback{margin:14px 0}.ui-card>.ui-feedback:last-child{margin-bottom:0}.ui-feedback-detail{color:var(--ui-text-muted);overflow-wrap:anywhere;margin-top:4px;font-size:12.5px;display:block}.ui-placeholder{border:.5px dashed var(--ui-border-strong);color:var(--ui-text-muted);text-align:center;border-radius:12px;margin:0 0 14px;padding:18px;font-size:13.5px}.ui-note{color:var(--ui-text-muted);margin:12px 0 0;font-size:12.5px;line-height:1.6}.ui-info{border:.5px solid var(--ui-border-strong);width:1.3em;height:1.3em;color:var(--ui-text-muted);cursor:help;vertical-align:middle;border-radius:50%;justify-content:center;align-items:center;margin-left:.3em;font-size:.72em;font-style:normal;font-weight:500;line-height:1;display:inline-flex}.ui-info:hover,.ui-info:focus-visible{border-color:var(--ui-accent);color:var(--ui-accent);outline:none}.ui-ptb-graph{min-height:60px;color:var(--ui-text-muted);font-size:13px;overflow-x:auto}.ui-ptb-graph svg{max-width:100%;height:auto}.ui-ptb-graph--error{color:var(--ui-danger)}.ui-chain-receipt-gas{margin-bottom:6px}.ui-chain-receipt-ptb{background:var(--ui-surface);min-width:0;overflow:hidden}.ui-ptb-actions{align-items:center;gap:4px;display:flex}.ui-ptb-graph-controls .ui-icon-btn{background:var(--ui-surface-2);box-shadow:0 1px 3px #0003}.ui-ptb-graph--interactive{cursor:grab;-webkit-user-select:none;user-select:none;touch-action:none;height:420px;position:relative;overflow:hidden}.ui-ptb-graph--grabbing{cursor:grabbing}.ui-ptb-graph-content{transform-origin:0 0;width:100%}.ui-ptb-graph-controls{z-index:2;flex-direction:column;gap:5px;display:flex;position:absolute;top:8px;right:8px}.ui-ptb-graph-controls .ui-icon-btn{width:28px;height:28px}.ui-ptb-graph-controls .ui-icon-btn svg{width:15px;height:15px}.ui-accordion{border-block-start:1px solid var(--ui-border);margin-block:12px}.ui-accordion-summary{cursor:pointer;color:var(--ui-text);justify-content:space-between;align-items:center;gap:10px;padding:11px 0;font-size:13px;font-weight:500;list-style:none;display:flex}.ui-accordion-summary::-webkit-details-marker{display:none}.ui-accordion-summary:hover{color:var(--ui-accent)}.ui-accordion-summary:focus-visible{box-shadow:0 0 0 3px var(--ui-focus);border-radius:var(--ui-r);outline:none}.ui-accordion-summary:after{content:"";border-right:1.5px solid var(--ui-text-muted);border-bottom:1.5px solid var(--ui-text-muted);flex:none;width:7px;height:7px;transition:transform .15s;transform:rotate(45deg)}.ui-accordion[open] .ui-accordion-summary:after{transform:rotate(-135deg)}.ui-accordion[open] .ui-accordion-summary{color:var(--ui-accent)}.ui-accordion-body{padding:4px 0 12px}.ui-accordion[open]>.ui-accordion-body{animation:.18s ease-out ui-reveal}@keyframes ui-reveal{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@media (prefers-reduced-motion:reduce){.ui-accordion[open]>.ui-accordion-body{animation:none}}@container mcp-card (width<=28rem){.ui-card{--ui-card-padding-block:12px;--ui-card-padding-inline:12px}.ui-row{grid-template-columns:minmax(0,1fr);gap:4px}.ui-row-value{text-align:left}.ui-detail-meta{flex-wrap:wrap}}@container mcp-card (width>=0){.ui-card,.ui-card-head>:first-child,.ui-detail-head>*,.ui-detail-meta>*{min-width:0}.ui-ptb-actions{flex:none}.ui-ptb-graph--interactive{height:clamp(280px,75cqi,420px)}}.ui-error:not(:empty){color:var(--ui-danger)}.ui-note:empty,.ui-error:empty{display:none}.ui-form{flex-wrap:wrap;align-items:end;gap:12px;display:flex}.ui-form>*{min-width:0;max-width:100%}.ui-form>input,.ui-form>select,.ui-form>label{flex:14rem}.ui-form label{flex-direction:column;gap:6px;display:flex}.ui-form label>input,.ui-form label>select{width:100%}.ui-form>details,.ui-form>p,.ui-form>.card-actions{flex-basis:100%}@container mcp-card (width<=28rem){.ui-form>button{width:100%}}.settings-card{overflow-x:clip}.settings-card .settings-page--forward{animation:.18s ease-out settings-forward}.settings-card .settings-page--back{animation:.18s ease-out settings-back}@keyframes settings-forward{0%{opacity:0;transform:translate(16px)}to{opacity:1;transform:translate(0)}}@keyframes settings-back{0%{opacity:0;transform:translate(-16px)}to{opacity:1;transform:translate(0)}}@media (prefers-reduced-motion:reduce){.settings-card .settings-page--forward,.settings-card .settings-page--back{animation:none}}.settings-card .settings-toolbar{border-bottom:1px solid var(--ui-border);flex-wrap:wrap;align-items:center;gap:12px;margin-block-end:20px;padding-block:0 14px;display:flex}.settings-card .settings-location{color:var(--ui-text-muted);font-size:13px}.settings-card .settings-back{background:0 0;border-color:#0000;padding-inline:0 10px}.settings-card .settings-back:before{content:"←";margin-inline-end:8px}.settings-card .settings-menu{margin-block:16px;display:grid}.settings-card .settings-menu-item{text-align:start;white-space:normal;border:0;border-bottom:1px solid var(--ui-border);width:100%;color:var(--ui-text);background:0 0;border-radius:0;grid-template-columns:minmax(0,1fr);justify-content:stretch;justify-items:start;gap:5px;padding:18px 32px 18px 12px;display:grid;position:relative}.settings-card .settings-menu-item:hover{background:var(--ui-surface-2)}.settings-card .settings-menu-item:after{content:"";inset-inline-end:14px;border-top:1.5px solid var(--ui-text-muted);border-right:1.5px solid var(--ui-text-muted);width:7px;height:7px;position:absolute;top:50%;transform:translateY(-50%)rotate(45deg)}.settings-card .settings-menu-title{font-weight:600}.settings-card .settings-menu-description{color:var(--ui-text-muted);font-size:13px;font-weight:400}.settings-card .settings-pending{margin-block:20px}.settings-card .settings-action-row{align-items:stretch;gap:var(--ui-space-2,8px);grid-template-columns:minmax(0,1fr);margin-block-start:12px;display:grid}.settings-card .settings-action-row>.ui-btn{white-space:normal;overflow-wrap:anywhere;width:100%;min-width:0}.settings-card .settings-path{white-space:normal;overflow-wrap:anywhere}.settings-card .settings-backup-location .ui-row{grid-template-columns:minmax(0,1fr);gap:6px}.settings-card .settings-backup-location .ui-row-value{text-align:start}.settings-card .settings-choice{border-bottom:1px solid var(--ui-border);flex-wrap:wrap;align-items:center;gap:12px 20px;padding-block:18px;display:flex}.settings-card .settings-choice-copy{flex:16rem;min-width:0}.settings-card .settings-choice h3{margin-block:0 6px}.settings-card .settings-choice p{margin:0}.settings-card .settings-endpoint{border-bottom:1px solid var(--ui-border);padding-block:16px}.settings-card .settings-endpoint label{flex-direction:column;gap:8px;display:flex}html,body{min-height:0;margin:0}body{color:var(--ui-text);background:var(--ui-bg)}#app{padding:var(--ui-space-4,16px);overflow-wrap:anywhere;min-width:0;max-width:100%;container:mcp-card/inline-size}#app h1{margin:0 0 12px;font-size:20px;font-weight:500}.card-actions{margin-top:12px}.card-actions,.card-actions>div{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.card-chart{width:100%;min-width:0;height:clamp(280px,75cqi,400px)}.card-progress-hint{color:var(--ui-text-muted);align-items:center;gap:10px;margin-block:12px;font-size:12px;display:flex}.card-progress-hint[hidden]{display:none}
1
+ <!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Sui MCP</title><style>:root[data-theme=light]{--ui-bg:#f6f8fa;--ui-surface:#fff;--ui-surface-2:#eef1f5;--ui-border:#e3e8ef;--ui-border-strong:#cdd5e0;--ui-text:#18202b;--ui-text-muted:#5b6675;--ui-accent:#1565c0;--ui-accent-hover:#0d47a1;--ui-on-accent:#fff;--ui-focus:#1565c040;--ui-ok-bg:#e2f3e9;--ui-ok-text:#1b6b43;--ui-warn-bg:#fbeeda;--ui-warn-text:#8a5a08;--ui-danger:#b3261e;--ui-danger-bg:#fbe9e7;--ui-up:#1b7f43;--ui-down:#b3261e}:root[data-theme=dark]{--ui-bg:#0e141b;--ui-surface:#161d26;--ui-surface-2:#1e2733;--ui-border:#28323f;--ui-border-strong:#3a4859;--ui-text:#e7edf4;--ui-text-muted:#9aa7b6;--ui-accent:#4da2ff;--ui-accent-hover:#6fb8ff;--ui-on-accent:#06243f;--ui-focus:#4da2ff52;--ui-ok-bg:#10362a;--ui-ok-text:#7fe0b0;--ui-warn-bg:#3a2e16;--ui-warn-text:#f0c97a;--ui-danger:#ff8a80;--ui-danger-bg:#3a1f1d;--ui-up:#46c79e;--ui-down:#ff8a80}:root{--ui-r:10px;--ui-font-sans:ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;--ui-font-mono:ui-monospace, SFMono-Regular, Menlo, monospace}*,:before,:after{box-sizing:border-box}[hidden]{display:none!important}body{background:var(--ui-bg);color:var(--ui-text);font-family:var(--ui-font-sans);-webkit-font-smoothing:antialiased;margin:0;font-weight:400}.ui-mono{font-family:var(--ui-font-mono);overflow-wrap:anywhere;font-size:12.5px}.ui-btn{border:.5px solid var(--ui-border-strong);border-radius:var(--ui-r);background:var(--ui-surface);min-height:38px;color:var(--ui-text);font:inherit;cursor:pointer;justify-content:center;align-items:center;gap:7px;padding:0 16px;font-size:14px;font-weight:500;transition:background .12s,border-color .12s,transform 60ms;display:inline-flex}.ui-btn:hover{background:var(--ui-surface-2);border-color:var(--ui-accent)}.ui-btn:active{transform:scale(.975)}.ui-btn:focus-visible{box-shadow:0 0 0 3px var(--ui-focus);outline:none}.ui-btn--primary{background:var(--ui-accent);border-color:var(--ui-accent);color:var(--ui-on-accent)}.ui-btn--primary:hover{background:var(--ui-accent-hover);border-color:var(--ui-accent-hover)}.ui-btn--danger{border-color:var(--ui-danger);color:var(--ui-danger)}.ui-btn--danger:hover{background:var(--ui-danger-bg)}.ui-btn:disabled{cursor:not-allowed;color:var(--ui-text-muted);background:var(--ui-surface-2);border-color:var(--ui-border)}.ui-btn-row{flex-wrap:wrap;gap:10px;margin-top:12px;display:flex}.ui-btn-row>.ui-btn{flex:1 1 0;min-width:12rem}.ui-btn-row--end{justify-content:flex-end}.ui-btn-row--end>.ui-btn{flex:none;min-width:0}.ui-icon-btn{border:.5px solid var(--ui-border-strong);background:var(--ui-surface);width:34px;height:34px;color:var(--ui-text);cursor:pointer;border-radius:9px;flex:none;justify-content:center;align-items:center;padding:0;transition:background .12s,border-color .12s,transform 60ms;display:inline-flex}.ui-icon-btn:hover{background:var(--ui-surface-2);border-color:var(--ui-accent)}.ui-icon-btn:active{transform:scale(.94)}.ui-icon-btn:focus-visible{box-shadow:0 0 0 3px var(--ui-focus);outline:none}.ui-icon-btn svg{width:18px;height:18px}.ui-link{color:var(--ui-accent);cursor:pointer;text-decoration:none}.ui-link:hover{color:var(--ui-accent-hover);text-decoration:underline}.ui-field{color:var(--ui-text-muted);flex-direction:column;gap:5px;font-size:12px;display:flex}.ui-field--check{min-height:38px;color:var(--ui-text);cursor:pointer;flex-direction:row;align-items:center;gap:8px;font-size:14px}.ui-checkbox{font:inherit;width:1em;height:1em;accent-color:var(--ui-accent);cursor:inherit;flex:none;margin:0;padding:0}.ui-input,input.ui-input{border:.5px solid var(--ui-border-strong);border-radius:var(--ui-r);background:var(--ui-surface);height:38px;color:var(--ui-text);font:inherit;outline:none;padding:0 12px;font-size:14px;transition:border-color .12s,box-shadow .12s}.ui-input{width:100%}.ui-input::placeholder{color:var(--ui-text-muted)}.ui-select{border:.5px solid var(--ui-border-strong);border-radius:var(--ui-r);background:var(--ui-surface);width:100%;height:38px;color:var(--ui-text);font:inherit;cursor:pointer;outline:none;padding:0 12px;font-size:14px;transition:border-color .12s,box-shadow .12s}.ui-select:focus,.ui-input:focus{border-color:var(--ui-accent);box-shadow:0 0 0 3px var(--ui-focus)}.ui-card{background:var(--ui-surface);border:.5px solid var(--ui-border);padding:var(--ui-card-padding-block,16px) var(--ui-card-padding-inline,18px);border-radius:12px;margin:0 0 14px}.ui-section{min-width:0;margin-block:0 16px}.ui-section-title{justify-content:space-between;align-items:center;gap:10px;margin:0 0 10px;font-size:14px;font-weight:500;display:flex}.ui-card-title{margin:0 0 10px;font-size:14px;font-weight:500}.ui-card-head{margin:calc(-1 * var(--ui-card-padding-block,16px)) calc(-1 * var(--ui-card-padding-inline,18px)) 14px;padding:9px var(--ui-card-padding-inline,18px);background:var(--ui-surface-2);border-bottom:.5px solid var(--ui-border);border-radius:12px 12px 0 0;justify-content:space-between;align-items:center;gap:10px;font-size:14px;font-weight:500;display:flex}.ui-card-head+.ui-detail-item,.ui-card-head+.ui-row{border-top:0}.ui-row{border-top:.5px solid var(--ui-border);grid-template-columns:minmax(140px,.34fr) minmax(0,1fr);gap:12px;padding:9px 0;font-size:14px;display:grid}.ui-row:first-child{border-top:0}.ui-row-label{color:var(--ui-text-muted)}.ui-row-value{color:var(--ui-text);overflow-wrap:anywhere;font-variant-numeric:tabular-nums;text-align:right}.ui-status-banner{border-radius:var(--ui-r);border:.5px solid var(--ui-border-strong);background:var(--ui-surface-2);color:var(--ui-text);align-items:center;gap:9px;padding:11px 0;font-size:14px;font-weight:500;display:flex}.ui-status-icon{flex:none;display:inline-flex}.ui-status-icon svg{width:18px;height:18px}.ui-status-banner--success{background:var(--ui-ok-bg);color:var(--ui-ok-text);border-color:#0000}.ui-status-banner--failure{background:var(--ui-danger-bg);color:var(--ui-danger);border-color:#0000}.ui-status-banner--pending{color:var(--ui-text-muted)}.ui-detail-item{border-top:.5px solid var(--ui-border);padding:9px 0}.ui-detail-head{flex-wrap:wrap;justify-content:space-between;align-items:baseline;gap:12px;display:flex}.ui-detail-title{color:var(--ui-text);overflow-wrap:anywhere;font-weight:500}.ui-detail-trailing{color:var(--ui-text);overflow-wrap:anywhere}.ui-detail-trailing--up{color:var(--ui-up)}.ui-detail-trailing--down{color:var(--ui-down)}.ui-detail-meta{color:var(--ui-text-muted);overflow-wrap:anywhere;gap:8px;margin-top:3px;font-size:12.5px;display:flex}.ui-detail-metalabel{color:var(--ui-text-muted);flex:none}.ui-feedback{border:.5px solid var(--ui-border);background:var(--ui-surface);color:var(--ui-text);border-left-width:3px;border-radius:8px;margin:0 0 14px;padding:11px 13px;font-size:13.5px}.ui-feedback--ok{border-left-color:var(--ui-ok-text)}.ui-feedback--error{border-left-color:var(--ui-danger)}.ui-card>.ui-feedback{margin:14px 0}.ui-card>.ui-feedback:last-child{margin-bottom:0}.ui-feedback-detail{color:var(--ui-text-muted);overflow-wrap:anywhere;margin-top:4px;font-size:12.5px;display:block}.ui-placeholder{border:.5px dashed var(--ui-border-strong);color:var(--ui-text-muted);text-align:center;border-radius:12px;margin:0 0 14px;padding:18px;font-size:13.5px}.ui-note{color:var(--ui-text-muted);margin:12px 0 0;font-size:12.5px;line-height:1.6}.ui-info{border:.5px solid var(--ui-border-strong);width:1.3em;height:1.3em;color:var(--ui-text-muted);cursor:help;vertical-align:middle;border-radius:50%;justify-content:center;align-items:center;margin-left:.3em;font-size:.72em;font-style:normal;font-weight:500;line-height:1;display:inline-flex}.ui-info:hover,.ui-info:focus-visible{border-color:var(--ui-accent);color:var(--ui-accent);outline:none}.ui-ptb-graph{min-height:60px;color:var(--ui-text-muted);font-size:13px;overflow-x:auto}.ui-ptb-graph svg{max-width:100%;height:auto}.ui-ptb-graph--error{color:var(--ui-danger)}.ui-chain-receipt-gas{margin-bottom:6px}.ui-chain-receipt-ptb{background:var(--ui-surface);min-width:0;overflow:hidden}.ui-ptb-actions{align-items:center;gap:4px;display:flex}.ui-ptb-graph-controls .ui-icon-btn{background:var(--ui-surface-2);box-shadow:0 1px 3px #0003}.ui-ptb-graph--interactive{cursor:grab;-webkit-user-select:none;user-select:none;touch-action:none;height:420px;position:relative;overflow:hidden}.ui-ptb-graph--grabbing{cursor:grabbing}.ui-ptb-graph-content{transform-origin:0 0;width:100%}.ui-ptb-graph-controls{z-index:2;flex-direction:column;gap:5px;display:flex;position:absolute;top:8px;right:8px}.ui-ptb-graph-controls .ui-icon-btn{width:28px;height:28px}.ui-ptb-graph-controls .ui-icon-btn svg{width:15px;height:15px}.ui-accordion{border-block-start:1px solid var(--ui-border);margin-block:12px}.ui-accordion-summary{cursor:pointer;color:var(--ui-text);justify-content:space-between;align-items:center;gap:10px;padding:11px 0;font-size:13px;font-weight:500;list-style:none;display:flex}.ui-accordion-summary::-webkit-details-marker{display:none}.ui-accordion-summary:hover{color:var(--ui-accent)}.ui-accordion-summary:focus-visible{box-shadow:0 0 0 3px var(--ui-focus);border-radius:var(--ui-r);outline:none}.ui-accordion-summary:after{content:"";border-right:1.5px solid var(--ui-text-muted);border-bottom:1.5px solid var(--ui-text-muted);flex:none;width:7px;height:7px;transition:transform .15s;transform:rotate(45deg)}.ui-accordion[open] .ui-accordion-summary:after{transform:rotate(-135deg)}.ui-accordion[open] .ui-accordion-summary{color:var(--ui-accent)}.ui-accordion-body{padding:4px 0 12px}.ui-accordion[open]>.ui-accordion-body{animation:.18s ease-out ui-reveal}@keyframes ui-reveal{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}@media (prefers-reduced-motion:reduce){.ui-accordion[open]>.ui-accordion-body{animation:none}}@container mcp-card (width<=28rem){.ui-card{--ui-card-padding-block:12px;--ui-card-padding-inline:12px}.ui-row{grid-template-columns:minmax(0,1fr);gap:4px}.ui-row-value{text-align:left}.ui-detail-meta{flex-wrap:wrap}}@container mcp-card (width>=0){.ui-card,.ui-card-head>:first-child,.ui-detail-head>*,.ui-detail-meta>*{min-width:0}.ui-ptb-actions{flex:none}.ui-ptb-graph--interactive{height:clamp(280px,75cqi,420px)}}.ui-error:not(:empty){color:var(--ui-danger)}.ui-note:empty,.ui-error:empty{display:none}.ui-form{flex-wrap:wrap;align-items:end;gap:12px;display:flex}.ui-form>*{min-width:0;max-width:100%}.ui-form>input,.ui-form>select,.ui-form>label{flex:14rem}.ui-form label{flex-direction:column;gap:6px;display:flex}.ui-form label>input,.ui-form label>select{width:100%}.ui-form>details,.ui-form>p,.ui-form>.card-actions{flex-basis:100%}@container mcp-card (width<=28rem){.ui-form>button{width:100%}}.settings-card{overflow-x:clip}.settings-card .settings-page--forward{animation:.18s ease-out settings-forward}.settings-card .settings-page--back{animation:.18s ease-out settings-back}@keyframes settings-forward{0%{opacity:0;transform:translate(16px)}to{opacity:1;transform:translate(0)}}@keyframes settings-back{0%{opacity:0;transform:translate(-16px)}to{opacity:1;transform:translate(0)}}@media (prefers-reduced-motion:reduce){.settings-card .settings-page--forward,.settings-card .settings-page--back{animation:none}}.settings-card .settings-toolbar{border-bottom:1px solid var(--ui-border);flex-wrap:wrap;align-items:center;gap:12px;margin-block-end:20px;padding-block:0 14px;display:flex}.settings-card .settings-location{color:var(--ui-text-muted);font-size:13px}.settings-card .settings-back{background:0 0;border-color:#0000;padding-inline:0 10px}.settings-card .settings-back:before{content:"←";margin-inline-end:8px}.settings-card .settings-menu{margin-block:16px;display:grid}.settings-card .settings-menu-item{text-align:start;white-space:normal;border:0;border-bottom:1px solid var(--ui-border);width:100%;color:var(--ui-text);background:0 0;border-radius:0;grid-template-columns:minmax(0,1fr);justify-content:stretch;justify-items:start;gap:5px;padding:18px 32px 18px 12px;display:grid;position:relative}.settings-card .settings-menu-item:hover{background:var(--ui-surface-2)}.settings-card .settings-menu-item:after{content:"";inset-inline-end:14px;border-top:1.5px solid var(--ui-text-muted);border-right:1.5px solid var(--ui-text-muted);width:7px;height:7px;position:absolute;top:50%;transform:translateY(-50%)rotate(45deg)}.settings-card .settings-menu-title{font-weight:600}.settings-card .settings-menu-description{color:var(--ui-text-muted);font-size:13px;font-weight:400}.settings-card .settings-pending{margin-block:20px}.settings-card .settings-action-row{align-items:stretch;gap:var(--ui-space-2,8px);grid-template-columns:minmax(0,1fr);margin-block-start:12px;display:grid}.settings-card .settings-action-row>.ui-btn{white-space:normal;overflow-wrap:anywhere;width:100%;min-width:0}.settings-card .settings-path{white-space:normal;overflow-wrap:anywhere}.settings-card .settings-backup-location .ui-row{grid-template-columns:minmax(0,1fr);gap:6px}.settings-card .settings-backup-location .ui-row-value{text-align:start}.settings-card .settings-choice{border-bottom:1px solid var(--ui-border);flex-wrap:wrap;align-items:center;gap:12px 20px;padding-block:18px;display:flex}.settings-card .settings-choice-copy{flex:16rem;min-width:0}.settings-card .settings-choice h3{margin-block:0 6px}.settings-card .settings-choice p{margin:0}.settings-card .settings-endpoint{border-bottom:1px solid var(--ui-border);padding-block:16px}.settings-card .settings-endpoint label{flex-direction:column;gap:8px;display:flex}html,body{min-height:0;margin:0}body{color:var(--ui-text);background:var(--ui-bg)}#app{padding:var(--ui-space-4,16px);overflow-wrap:anywhere;min-width:0;max-width:100%;container:mcp-card/inline-size}#app h1{margin:0 0 12px;font-size:20px;font-weight:500}.card-actions{margin-top:12px}.card-actions,.card-actions>div{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.card-chart{width:100%;min-width:0;height:clamp(280px,75cqi,400px)}.card-progress-hint{color:var(--ui-text-muted);align-items:center;gap:10px;margin-block:12px;font-size:12px;display:flex}
2
2
  /*$vite$:1*/</style></head><body><main id="app" aria-live="polite"></main><template id="dependency-notices">@modelcontextprotocol/client 2.3.1
3
3
  The MCP project is undergoing a licensing transition from the MIT License to the Apache License, Version 2.0 ("Apache-2.0"). All new code and specification contributions to the project are licensed under Apache-2.0. Documentation contributions (excluding specifications) are licensed under CC-BY-4.0.
4
4
 
@@ -1761,7 +1761,7 @@ Boolean requesting whether a visible border and background is provided by the ho
1761
1761
  - omitted: host decides border`)}),B({method:G(`ui/request-display-mode`),params:B({mode:wh.describe(`The display mode being requested.`)})});var Vh=B({mode:wh.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough(),Hh=H([G(`model`),G(`app`)]).describe(`Tool visibility scope - who can access the tool.`);B({resourceUri:F().optional(),visibility:z(Hh).optional().describe(`Who can access this tool. Default: ["model", "app"]
1762
1762
  - "model": Tool visible to and callable by the agent
1763
1763
  - "app": Tool callable by the app from this server only`),csp:uc().optional(),permissions:uc().optional()}),B({mimeTypes:z(F()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),B({method:G(`ui/download-file`),params:B({contents:z(H([zu,Bu])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),B({method:G(`ui/message`),params:B({role:G(`user`).describe(`Message role, currently only "user" is supported.`),content:z(Vu).describe(`Message content blocks (text, image, etc.).`)})}),B({method:G(`ui/notifications/sandbox-resource-ready`),params:B({html:F().describe(`HTML content to load into the inner iframe.`),sandbox:F().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:kh.optional().describe(`CSP configuration from resource metadata.`),permissions:Ah.optional().describe(`Sandbox permissions from resource metadata.`)})});var Uh=B({method:G(`ui/notifications/tool-result`),params:Xu.describe(`Standard MCP tool execution result.`)}),Wh=B({toolInfo:B({id:xl.optional().describe(`JSON-RPC id of the tools/call request.`),tool:qu.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:Ch.optional().describe(`Current color theme preference.`),styles:Fh.optional().describe(`Style configuration for theming the app.`),displayMode:wh.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:z(wh).optional().describe(`Display modes the host supports.`),containerDimensions:H([B({height:I().describe(`Fixed container height in pixels.`)}),B({maxHeight:H([I(),rc()]).optional().describe(`Maximum container height in pixels.`)})]).and(H([B({width:I().describe(`Fixed container width in pixels.`)}),B({maxWidth:H([I(),rc()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
1764
- container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:F().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:F().optional().describe(`User's timezone in IANA format.`),userAgent:F().optional().describe(`Host application identifier.`),platform:H([G(`web`),G(`desktop`),G(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:B({touch:L().optional().describe(`Whether the device supports touch input.`),hover:L().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:B({top:I().describe(`Top safe area inset in pixels.`),right:I().describe(`Right safe area inset in pixels.`),bottom:I().describe(`Bottom safe area inset in pixels.`),left:I().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),Gh=B({method:G(`ui/notifications/host-context-changed`),params:Wh.describe(`Partial context update containing only changed fields.`)});B({method:G(`ui/update-model-context`),params:B({content:z(Vu).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:U(F(),R().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),B({method:G(`ui/initialize`),params:B({appInfo:Pl.describe(`App identification (name and version).`),appCapabilities:Bh.describe(`Features and capabilities this app provides.`),protocolVersion:F().describe(`Protocol version this app supports.`)})});var Kh=B({protocolVersion:F().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Pl.describe(`Host application identification and version.`),hostCapabilities:zh.describe(`Features and capabilities provided by the host.`),hostContext:Wh.describe(`Rich context about the host environment.`)}).passthrough(),qh={target:`draft-2020-12`};async function Jh(e,t){let n=e[`~standard`];if(n.jsonSchema)return n.jsonSchema[t](qh);throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function Yh(e,t,n=``){let r=await e[`~standard`].validate(t);if(r.issues){let e=r.issues.map(e=>{let t=e.path?.map(e=>typeof e==`object`?e.key:e).join(`.`);return t?`${t}: ${e.message}`:e.message}).join(`; `);throw Error(n+e)}return r.value}function Xh(e,t){let n={...e,...t};return t.experimental!==void 0&&(n.experimental={...e.experimental,...t.experimental}),t.tools!==void 0&&(n.tools={...e.tools,...t.tools}),n}var Zh=class e extends Zm{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new gh;_methods=new _h;setRequestHandler=(...e)=>{let[t,...n]=yh(`request`,e)??e;this._methods.claim(t,`setRequestHandler`),super.setRequestHandler.call(this,t,...n)};setNotificationHandler=(...e)=>{let[t,...n]=yh(`notification`,e)??e;this._methods.claim(t,`setNotificationHandler`),super.setNotificationHandler.call(this,t,...n)};removeRequestHandler=e=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=e=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:jh,toolinputpartial:Mh,toolresult:Uh,toolcancelled:Nh,hostcontextchanged:Gh};static ONE_SHOT_EVENTS=new Set([`toolinput`,`toolinputpartial`,`toolresult`,`toolcancelled`]);_everHadListener=new Set;_assertHandlerTiming(t){if(!e.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(e,t){t&&this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.setHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},t=>{let n=t;e===`hostcontextchanged`&&(this._hostContext={...this._hostContext,...n}),this._events.dispatch(e,n)}),this._registeredEvents.add(e)}getEventHandler(e){return this._events.getHandler(e)}warnIfRequestHandlerReplaced(e,t,n){t&&n&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._appCapabilities=t,this.options=n,this._methods.replace(`notifications/cancelled`),this._methods.replace(`notifications/progress`),!n.allowUnsafeEval&&Ye({jitless:!0}),this.replaceRequestHandler(`ping`,e=>(console.log(`Received ping:`,e.params),{})),this.setEventHandler(`hostcontextchanged`,void 0)}buildContext(e){return e}registerAppCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after transport is established`);this._appCapabilities=Xh(this._appCapabilities,e)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,i=()=>{r._initializedSent&&r._appCapabilities.tools?.listChanged&&r.sendToolListChanged()},a=t.inputSchema!==void 0,o={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(e){Object.assign(this,e),i()},remove(){r._registeredTools[e]===o&&(delete r._registeredTools[e],i())},handler:async(t,r)=>{if(!o.enabled)throw Error(`Tool ${e} is disabled`);let i;if(a){let a=o.inputSchema;i=await n(a?await Yh(a,t??{},`Invalid input for tool ${e}: `):t??{},r)}else i=await n(r);return o.outputSchema&&!i.isError&&(i.structuredContent=await Yh(o.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=o,!this._appCapabilities.tools&&!this.transport&&this.registerAppCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),o}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let n=this._registeredTools[e.name];if(!n)throw Error(`Tool ${e.name} not found`);return n.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([e,t])=>t.enabled).map(async([e,t])=>{let n={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?await Jh(t.inputSchema,`input`):{type:`object`,properties:{}}};return t.outputSchema&&(n.outputSchema=await Jh(t.outputSchema,`output`)),t.annotations&&(n.annotations=t.annotations),t._meta&&(n._meta=t._meta),n}))}))}async sendToolListChanged(e={}){this._assertInitialized(`sendToolListChanged`),await this.notification({method:`notifications/tools/list_changed`,params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler(`toolinput`)}set ontoolinput(e){this.setEventHandler(`toolinput`,e)}get ontoolinputpartial(){return this.getEventHandler(`toolinputpartial`)}set ontoolinputpartial(e){this.setEventHandler(`toolinputpartial`,e)}get ontoolresult(){return this.getEventHandler(`toolresult`)}set ontoolresult(e){this.setEventHandler(`toolresult`,e)}get ontoolcancelled(){return this.getEventHandler(`toolcancelled`)}set ontoolcancelled(e){this.setEventHandler(`toolcancelled`,e)}get onhostcontextchanged(){return this.getEventHandler(`hostcontextchanged`)}set onhostcontextchanged(e){this.setEventHandler(`hostcontextchanged`,e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced(`onteardown`,this._onteardown,e),this._onteardown=e,this.replaceRequestHandler(`ui/resource-teardown`,{params:Ih.shape.params,result:Lh},(e,t)=>{if(!this._onteardown)throw Error(`No onteardown handler set`);return this._onteardown(e,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(`tools/call`,(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced(`onlisttools`,this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler(`tools/list`,(e,t)=>{if(!this._onlisttools)throw Error(`No onlisttools handler set`);return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){if(e===`sampling/createMessage`&&!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`)}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;default:return}}assertNotificationCapability(e){}async callServerTool(e,t){if(this._assertInitialized(`callServerTool`),typeof e==`string`)throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:`tools/call`,params:e},{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized(`readServerResource`),await this.request({method:`resources/read`,params:e},t)}async listServerResources(e,t){return this._assertInitialized(`listServerResources`),await this.request({method:`resources/list`,params:e},t)}async createSamplingMessage(e,t){return this._assertInitialized(`createSamplingMessage`),await this.request({method:`sampling/createMessage`,params:e},t)}sendMessage(e,t){return this._assertInitialized(`sendMessage`),this.request({method:`ui/message`,params:e},Oh,t)}sendLog(e){return this.notification({method:`notifications/message`,params:e})}updateModelContext(e,t){return this._assertInitialized(`updateModelContext`),this.request({method:`ui/update-model-context`,params:e},Ol,t)}openLink(e,t){return this._assertInitialized(`openLink`),this.request({method:`ui/open-link`,params:e},Eh,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized(`downloadFile`),this.request({method:`ui/download-file`,params:e},Dh,t)}requestTeardown(e={}){return this.notification({method:`ui/notifications/request-teardown`,params:e})}requestDisplayMode(e,t){return this._assertInitialized(`requestDisplayMode`),this.request({method:`ui/request-display-mode`,params:e},Vh,t)}sendSizeChanged(e){return this.notification({method:`ui/notifications/size-changed`,params:e})}setupSizeChangedNotifications(){let e=!1,t=0,n=0,r=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let r=document.documentElement,i=r.style.height;r.style.height=`max-content`;let a=Math.ceil(r.getBoundingClientRect().height);r.style.height=i;let o=Math.ceil(window.innerWidth);(o!==t||a!==n)&&(t=o,n=a,this.sendSizeChanged({width:o,height:a}))}))};r();let i=new ResizeObserver(r);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(e=new Sh(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);this._initializedSent=!1;try{await super.connect(e);let n=await this.request({method:`ui/initialize`,params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:xh}},Kh,t);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);this._hostCapabilities=n.hostCapabilities,this._hostInfo=n.hostInfo,this._hostContext=n.hostContext,await this.notification({method:`ui/notifications/initialized`}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(e){throw this.close(),e}}};function Qh(e){let t=new Date(e);return Number.isFinite(t.getTime())?`${t.toISOString().slice(0,19).replace(`T`,` `)} UTC`:typeof e==`number`?`${e} milliseconds since 1970-01-01T00:00:00Z`:e}function $h(e,t,n){let r=document.createElement(e);return t&&(r.className=t),n!==void 0&&(r.textContent=n),r}function eg(e,t,n=`primary`){let r=document.createElement(`button`);return r.type=`button`,r.className=n===`primary`?`ui-btn ui-btn--primary`:n===`danger`?`ui-btn ui-btn--danger`:`ui-btn`,r.textContent=e,r.addEventListener(`click`,t),r}function tg(e,t){let n=document.createElement(`a`);return n.className=`ui-link`,n.textContent=e,n.href=t,n}function ng(e){let t=document.createElement(`input`);return t.className=`ui-input`,t.type=e.type??`text`,e.value!==void 0&&(t.value=e.value),e.placeholder!==void 0&&(t.placeholder=e.placeholder),e.id&&(t.id=e.id),e.name&&(t.name=e.name),t.autocomplete=`off`,t}function rg(e,t){let n=document.createElement(`label`);return n.className=`ui-field`,n.append($h(`span`,void 0,e),t),n}function ig(e){let t=document.createElement(`select`);t.className=`ui-select`;for(let n of e.choices){let r=document.createElement(`option`);r.value=n.value,r.textContent=n.label,e.value===n.value&&(r.selected=!0),t.append(r)}return e.id&&(t.id=e.id),e.name&&(t.name=e.name),e.onChange&&t.addEventListener(`change`,()=>e.onChange(t.value)),t}function ag(e,t=!1){let n=document.createElement(`details`);n.className=`ui-accordion`,n.open=t;let r=document.createElement(`summary`);r.className=`ui-accordion-summary`,r.append($h(`span`,void 0,e));let i=$h(`div`,`ui-accordion-body`);return n.append(r,i),{details:n,body:i}}function og(e){let t=$h(`time`,void 0,Qh(e));return t.dateTime=e,t.title=e,t.setAttribute(`aria-label`,e),t}var sg=/^(?!.*(^(?!@)|[-.@])($|[-.@]))(?:[a-z0-9-]{0,63}(?:\.[a-z0-9-]{0,63})*)?@[a-z0-9-]{0,63}$/i,cg=/^(?!.*(^|[-.])($|[-.]))(?:[a-z0-9-]{0,63}\.)+sui$/i,lg=235;function ug(e){return e.length>lg?!1:e.includes(`@`)?sg.test(e):cg.test(e)}var dg=/^([a-z0-9]+(?:-[a-z0-9]+)*)$/,fg=/^\d+$/,pg=64,mg=e=>{let t=e.split(`/`);if(t.length<2||t.length>3)return!1;let[n,r,i]=t;return i!==void 0&&!fg.test(i)||!ug(n)?!1:dg.test(r)&&r.length<pg},hg=e=>Object.freeze(e());function gg(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}function _g(e){if(!gg(e))throw TypeError(`Uint8Array expected`)}function vg(e,t){if(typeof t!=`string`)throw TypeError(`${e}: string expected`);return!0}var yg=(()=>{try{let e=new TextDecoder;return e.decode(Uint8Array.of(65,48,43,127))===`A0+`?e:void 0}catch{return}})(),bg=8192;function xg(e){let t=e.length;if(yg!==void 0&&t>=12)return yg.decode(e);if(t<=bg)return String.fromCharCode.apply(null,e);let n=``;for(let r=0;r<t;r+=bg)n+=String.fromCharCode.apply(null,e.subarray(r,r+bg));return n}function Sg(e,t){let n=e.length;if(n>128)throw Error(`alphabet: max 128 letters`);let r=new Uint8Array(n),i=new Int8Array(128).fill(-1);for(let t=0;t<n;t++){let n=e.charCodeAt(t);if(e.codePointAt(t)!==n||n>127)throw Error(`alphabet: single-char ASCII letters only`);r[t]=n,i[n]=t}if(t!==void 0)for(let e of Object.keys(t)){let n=e.charCodeAt(0),r=i[t[e].charCodeAt(0)];if(e.length!==1||n>127||r===void 0||r===-1)throw Error(`alphabet: invalid alias ${e}`);i[n]=r}return{encode:e=>{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++){let i=e[n],a=r[i];if(a===void 0)throw Error(`alphabet.encode: invalid digit ${i}`);t[n]=a}return xg(t)},decode:t=>{vg(`decode`,t);let n=t.length,r=new Uint8Array(n);for(let a=0;a<n;a++){let n=t.charCodeAt(a),o=n<128?i[n]:-1;if(o===-1)throw Error(`Unknown letter "${t[a]}". Allowed: ${e}`);r[a]=o}return r}}}var Cg=656356768,wg=65536,Tg=2048,Eg=4096,Dg=(e,t)=>({encode:n=>{_g(n);let r=n.length;if(r===0)return new Uint8Array;if(r>=wg)throw Error(`invalid length`);let i=0;for(;i<r-1&&n[i]===0;)i++;let a=Math.ceil(r/2),o=new Uint16Array(a),s=r&1;s&&(o[0]=n[0]);for(let e=s,t=s;e<r;e+=2,t++)o[t]=n[e]<<8|n[e+1];let c=[],l=0;for(;l<a;){let e=0;for(let n=l;n<a;n++){let r=e*65536+o[n],i=Math.floor(r/t);e=r-i*t,o[n]=i,i===0&&n===l&&l++}c.push(e)}let u=c.length-1,d=u*5;for(let t=c[u];d++,!(t<e);t=Math.floor(t/e));let f=new Uint8Array(i+d),p=f.length-1;for(let t=0;t<u;t++){let n=c[t];for(let t=0;t<5;t++)f[p--]=n%e,n=Math.floor(n/e)}for(let t=c[u];p>=i;t=Math.floor(t/e))f[p--]=t%e;return f},decode:t=>{_g(t);let n=t.length;if(n===0)return new Uint8Array;if(n>=wg)throw Error(`invalid length`);let r=0;for(;r<n-1&&t[r]===0;)r++;let i=new Uint16Array(Math.ceil(n*6/16)+1),a=0,o=0,s=n%5||5;for(;o<n;){let n=0,r=1;for(let i=o+s;o<i;o++){let i=t[o];if(i>=e)throw Error(`invalid integer: ${i}`);n=n*e+i,r*=e}s=5;let c=n;for(let e=0;e<a;e++){let t=i[e]*r+c;c=Math.floor(t/65536),i[e]=t-c*65536}for(;c>0;c=Math.floor(c/65536))i[a++]=c%65536}let c=a===0?1:a*2-(i[a-1]<256),l=new Uint8Array(r+c),u=l.length-1;for(let e=0;e<a;e++){let t=i[e];l[u--]=t&255,u>=r&&(l[u--]=t>>8)}return l}}),Og=(e,t)=>{let n=Sg(t);return{encode(t){if(_g(t),t.length>Tg)throw Error(`invalid length`);return n.encode(e.encode(t))},decode(t){if(vg(`baseN.decode`,t),t.length>Eg)throw Error(`invalid length`);return e.decode(n.decode(t))}}},kg=Dg(58,Cg),Ag=e=>Og(kg,e),jg=hg(()=>Ag(`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`)),Mg=e=>jg.decode(e);function Ng(e,t=[`<`,`>`]){let[n,r]=t,i=[],a=``,o=0;for(let t=0;t<e.length;t++){let s=e[t];s===n&&o++,s===r&&o--,o===0&&s===`,`?(i.push(a.trim()),a=``):a+=s}return i.push(a.trim()),i}var Pg=32;function Fg(e){try{return Mg(e).length===Pg}catch{return!1}}function Ig(e){return Vg(e)&&Hg(e)===32}function Lg(e){if(e.startsWith(`vector<`)){if(!e.endsWith(`>`))throw Error(`Invalid type tag: ${e}`);let t=e.slice(7,-1);if(!t)throw Error(`Invalid type tag: ${e}`);let n=Lg(t);return typeof n==`string`?`vector<${n}>`:`vector<${zg(n)}>`}return e.includes(`::`)?Rg(e):e}function Rg(e){let t=e.split(`::`);if(t.length<3)throw Error(`Invalid struct tag: ${e}`);let[n,r]=t;if(!n||!r)throw Error(`Invalid struct tag: ${e}`);let i=mg(n),a=e.slice(n.length+r.length+4),o=a.includes(`<`)?a.slice(0,a.indexOf(`<`)):a;if(!o||a.includes(`<`)&&!a.endsWith(`>`))throw Error(`Invalid struct tag: ${e}`);let s=a.includes(`<`)?Ng(a.slice(a.indexOf(`<`)+1,a.lastIndexOf(`>`))).map(e=>Lg(e.trim())):[];return{address:i?n:Bg(n),module:r,name:o,typeParams:s}}function zg(e){if(typeof e==`string`&&e.startsWith(`vector<`))throw Error(`normalizeStructTag does not support vector types. Use normalizeTypeTag instead.`);let{address:t,module:n,name:r,typeParams:i}=typeof e==`string`?Rg(e):e;return`${t}::${n}::${r}${i?.length>0?`<${i.map(e=>typeof e==`string`?e:zg(e)).join(`,`)}>`:``}`}function Bg(e,t=!1){let n=e.toLowerCase();return!t&&n.startsWith(`0x`)&&(n=n.slice(2)),`0x${n.padStart(64,`0`)}`}function Vg(e){return/^(0x|0X)?[a-fA-F0-9]+$/.test(e)&&e.length%2==0}function Hg(e){return/^(0x|0X)/.test(e)?(e.length-2)/2:e.length/2}function Ug(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}var Wg=e=>e?`"${e}" `:``;function Gg(e,t=``){if(typeof e!=`number`)throw TypeError(Wg(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(Wg(t)+`expected integer >= 0, got `+e);return e}function Kg(e,t,n=``){if(Ug(e)&&(t===void 0||e.length===t))return e;t!==void 0&&Gg(t,`length`);let r=Ug(e),i=t===void 0?``:` of length ${t}`,a=r?`length=${e.length}`:`type=${typeof e}`,o=Wg(n)+`expected Uint8Array`+i+`, got `+a;throw r?RangeError(o):TypeError(o)}var qg=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError((t===`object`?``:`"${t}" `)+`expected object, got type=`+typeof e)},Jg=(e,t)=>{qg(e,t);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,`__proto__`))throw TypeError(`"${t}.__proto__" is not allowed`)};function Yg(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function Xg(e,t){Kg(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function Zg(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Qg(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function $g(e,t){return e<<32-t|e>>>t}function e_(e,t,n=`opts`){return Jg(e,`defaults`),t!==void 0&&Jg(t,n),Object.assign(Object.create(null),e,t)}function t_(e,t={}){if(typeof e!=`function`)throw TypeError(`"hashCons" expected function, got type=`+typeof e);t=e_({},t,`info`);let n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}var n_=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])}),r_=e=>e/2**32|0,i_=e=>e>>>0;function a_(e,t,n,r){let i=r_(n),a=i_(n);e.setUint32(t,r?a:i,r),e.setUint32(t+4,r?i:a,r)}function o_(e,t,n){return e&t^~e&n}function s_(e,t,n){return e&t^e&n^t&n}var c_=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Qg(this.buffer)}update(e){Yg(this),Kg(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length,a=!1;for(let o=0;o<i;){let s=Math.min(r-this.pos,i-o);if(s===r){let t=Qg(e);for(;r<=i-o;o+=r)this.process(t,o);a=!0}else n.set(o===0&&s===i?e:e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0,a=!0)}return this.length+=e.length,a&&this.roundClean(),this}digestInto(e){Yg(this),Xg(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,t.fill(0,a),this.padOffset>r-a&&(this.process(n,0),t.fill(0)),a_(n,r-8,this.length*8,i),this.process(n,0),this.roundClean();let o=e===t?n:Qg(e),s=this.outputLen,c=s/4,l=this.get();if(s%4||c>l.length)throw Error(`invalid outputLen`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:t,length:n,finished:r,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=r,e.length=n,e.pos=a,a&&e.buffer.set(t),e}clone(){return this._cloneInto()}},l_=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u_=`0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI`,d_=F().refine(Ig,`Expected a 32-byte Sui address`),f_=F().refine(Fg,`Expected a Sui transaction digest`);d_.transform(e=>Bg(e));var p_=(1n<<64n)-1n,m_=/^(?:0|[1-9][0-9]*)$/,h_=/^(?:0|-?[1-9][0-9]*)$/;function g_(e,t,n={}){if(!/^\d+$/.test(e))throw Error(`${t} must be an unsigned integer string`);let r=BigInt(e);if(n.positive&&r===0n)throw Error(`${t} must be positive`);if(r>p_)throw Error(`${t} must fit u64`);return r}function __(e){let t=e===`rawAmount`?`amount`:e;return F().min(1).refine(t=>{try{return g_(t,e),!0}catch{return!1}},`Expected a raw u64 ${t} string`)}function v_(e,t,n={}){if(!m_.test(e))throw Error(`${t} must be a canonical unsigned integer string`);return g_(e,t,n)}function y_(e){return F().min(1).refine(t=>{try{return v_(t,e),!0}catch{return!1}},`Expected an unsigned integer string`)}function b_(e,t){if(!h_.test(e))throw Error(`${t} must be a signed integer string`);return BigInt(e)}function x_(e){return F().min(1).refine(t=>{try{return b_(t,e),!0}catch{return!1}},`Expected a signed integer string`)}function S_(e){return zg(e)}var C_=[`transaction`,`effects`,`balanceChanges`,`objectTypes`],w_=F().refine(e=>{let t=new Date(e);return Number.isFinite(t.getTime())&&t.toISOString()===e},`Expected ISO 8601 UTC timestamp`),T_=z(W(C_)).length(C_.length).superRefine((e,t)=>{for(let n of C_)e.includes(n)||t.addIssue({code:`custom`,path:[],message:`chain receipt include is missing '${n}'`});new Set(e).size!==e.length&&t.addIssue({code:`custom`,path:[],message:`chain receipt include fields must not be duplicated`})}),E_=F().min(1).max(512).refine(e=>{try{return S_(e),!0}catch{return!1}},`Expected a Sui struct tag coin type`),D_=B({commandIndex:I().int().nonnegative(),packageId:d_,module:F().min(1).max(128),function:F().min(1).max(128),target:F().min(1).max(512)}).strict().superRefine((e,t)=>{let n=`${e.packageId}::${e.module}::${e.function}`;e.target!==n&&t.addIssue({code:`custom`,path:[`target`],message:`package call target must match packageId::module::function`})}),O_=B({index:I().int().nonnegative(),coinType:E_,amountRaw:x_(`accountBalanceChanges[].amountRaw`),direction:W([`increase`,`decrease`,`zero`])}).strict().superRefine((e,t)=>{let n=b_(e.amountRaw,`accountBalanceChanges[].amountRaw`),r=n>0n?`increase`:n<0n?`decrease`:`zero`;e.direction!==r&&t.addIssue({code:`custom`,path:[`direction`],message:`balance change direction must match amountRaw sign`})}),k_=hc(`success`,[B({success:G(!0),errorKind:uc().optional(),errorMessage:uc().optional()}).strict(),B({success:G(!1),errorKind:F().min(1).max(200).optional(),errorMessage:F().min(1).max(2e3).optional()}).strict()]),A_=B({kind:G(`sui_chain_receipt_v1`),source:B({method:G(`client.core.getTransaction`),network:G(`sui:mainnet`),chainIdentifier:F().min(1),fetchedAt:w_,include:T_}).strict(),txDigest:f_,sender:d_,effectsStatus:k_,packageCalls:z(D_),accountBalanceChanges:z(O_),objectTypes:U(d_,F().min(1).max(512))}).strict(),j_=W([`awaiting_signature`,`submitting`,`awaiting_chain_result`,`stopped`,`request_failed`,`outcome_unknown`,`completed`]),M_=B({reviewSessionId:F().min(1),attemptId:F().min(1),planId:F().min(1),status:W([`success`,`failure`]),txDigest:f_,chainReceipt:A_,failureReason:G(`chain_execution_failed`).optional(),recordedAt:F().datetime()}).strict().superRefine((e,t)=>{(e.txDigest!==e.chainReceipt.txDigest||e.status===`success`!==e.chainReceipt.effectsStatus.success)&&t.addIssue({code:`custom`,message:`Execution must match the observed chain receipt.`}),e.status===`failure`!=(e.failureReason!==void 0)&&t.addIssue({code:`custom`,message:`Only a chain failure has a chain execution failure reason.`})}),N_=B({attemptId:F().min(1),reviewSessionId:F().min(1),planId:F().min(1),reviewRevision:I().int().nonnegative(),account:d_,transactionDigest:f_,requestStatus:j_,revision:I().int().nonnegative(),createdAt:F().datetime(),updatedAt:F().datetime(),signatureVerifiedAt:F().datetime().optional(),submittedAt:F().datetime().optional(),reason:F().optional(),execution:M_.optional()}).strict().superRefine((e,t)=>{let n=e.execution;e.requestStatus===`completed`!=(n!==void 0)&&t.addIssue({code:`custom`,message:`Completed requests require an observed execution result.`}),n&&(n.attemptId!==e.attemptId||n.reviewSessionId!==e.reviewSessionId||n.planId!==e.planId||n.txDigest!==e.transactionDigest||n.chainReceipt.sender!==e.account)&&t.addIssue({code:`custom`,message:`Execution identity differs from the admitted request.`})}),P_=`sui:mainnet`,F_=F().uuid(),I_=W([`process_start`,`sdk_start`,`session_restore`,`state_sync`]),L_=W([`initialization_failed`,`restoration_failed`,`wallet_state_unavailable`]),R_=hc(`status`,[B({status:G(`available`),walletRunId:F_}).strict(),B({status:G(`initializing`),walletRunId:F_,stage:I_,message:F()}).strict(),B({status:G(`recovering`),walletRunId:F_,message:F()}).strict(),B({status:G(`unavailable`),walletRunId:F_.optional(),reason:L_,message:F()}).strict()]),z_=hc(`status`,[B({status:G(`idle`)}).strict(),B({status:G(`waiting`)}).strict(),B({status:G(`unavailable`),reason:G(`wallet_unavailable`),message:F()}).strict()]),B_=W([`awaiting_approval`,`connected`,`rejected`,`failed`,`expired`,`stopped`,`disconnected`]);B({runId:F().uuid(),connections:z(B({connectionId:F().min(1),revision:I().int().nonnegative(),status:B_,accounts:z(d_),walletName:F().optional(),sdkPending:L(),disconnectPending:L()}).strict()),preparations:z(B({id:F().min(1),revision:I().int().nonnegative(),review_revision:I().int().nonnegative(),preparation_id:F().nullable(),wallet_connection_id:F().nullable()}).strict()),requests:z(B({attempt_id:F().min(1),revision:I().int().nonnegative(),request_status:j_,can_submit:I().int().min(0).max(1),sdk_pending:I().int().min(0).max(1),submit_pending:I().int().min(0).max(1),lookup_pending:I().int().min(0).max(1)}).strict())}).strict();var V_=B({connectionId:F().min(1),status:B_,revision:I().int().nonnegative(),accounts:z(d_),methods:z(F()),chain:G(P_),createdAt:F().datetime(),updatedAt:F().datetime(),expiresAt:F().datetime(),walletName:F().optional(),reason:F().optional()}).strict(),H_=B({reason:G(`multiple_connections`),connectionIds:z(F().min(1)).min(2).refine(e=>new Set(e).size===e.length)}).strict(),U_=hc(`status`,[B({status:G(`available`),account:d_}).strict(),B({status:G(`address_required`)}).strict()]),W_=[`connect`,`disconnect`,`use_account`,`stop_connection`,`prepare_review`,`request_signature`,`cancel`,`stop_waiting`,`read_result`],G_=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),K_=new Uint32Array(64),q_=class extends c_{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(e,t){super(64,e,8,!1),this.A=t[0]|0,this.B=t[1]|0,this.C=t[2]|0,this.D=t[3]|0,this.E=t[4]|0,this.F=t[5]|0,this.G=t[6]|0,this.H=t[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,t){for(let n=0;n<16;n++,t+=4)K_[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=K_[e-15],n=K_[e-2],r=$g(t,7)^$g(t,18)^t>>>3,i=$g(n,17)^$g(n,19)^n>>>10;K_[e]=i+K_[e-7]+r+K_[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=$g(o,6)^$g(o,11)^$g(o,25),u=l+t+o_(o,s,c)+G_[e]+K_[e]|0,d=($g(n,2)^$g(n,13)^$g(n,22))+s_(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){Zg(K_)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Zg(this.buffer)}},J_=class extends q_{constructor(){super(32,l_)}},Y_=t_(()=>new J_,n_(1));function X_(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n>=55296&&n<=56319){if(t+1>=e.length)return!1;let n=e.charCodeAt(++t);if(n<56320||n>57343)return!1}else if(n>=56320&&n<=57343)return!1}return!0}function Z_(e){if(typeof e!=`string`)throw TypeError(`invalid mnemonic type: `+typeof e);if(!X_(e))throw TypeError(`expected well-formed Unicode string`);return e.normalize(`NFKD`)}function Q_(e){let t=Z_(e),n=t.split(` `);if(![12,15,18,21,24].includes(n.length))throw Error(`Invalid mnemonic`);return{nfkd:t,words:n}}function $_(e){if(Kg(e),![16,20,24,28,32].includes(e.length))throw RangeError(`invalid entropy length`)}var ev=e=>{let t=8-e.length/4;return Y_(e)[0]>>t<<t};function tv(e){if(!Array.isArray(e)||e.length!==2048||typeof e[0]!=`string`)throw TypeError(`Wordlist: expected array of 2048 strings`);e.forEach(e=>{if(typeof e!=`string`)throw TypeError(`wordlist: non-string element: `+e);if(!X_(e))throw TypeError(`wordlist: expected well-formed Unicode string`)})}function nv(e,t){tv(t);let n=e.length/3*4,r=new Uint8Array(n+1),i=0,a=0,o=0;for(let n of e){let e=t.indexOf(n);if(e===-1)throw Error(`Unknown word: `+n);for(i=i<<11|e,a+=11;a>=8;)a-=8,r[o++]=i>>>a&255;i&=(1<<a)-1}a>0&&(r[o]=i<<8-a);let s=r.subarray(0,n);if(r[n]!==ev(s))throw Error(`Invalid checksum`);return Uint8Array.from(s)}function rv(e,t){let{words:n}=Q_(e),r=nv(n,t);return $_(r),r}function iv(e,t){try{rv(e,t)}catch{return!1}return!0}var av=Object.freeze(`abandon
1764
+ container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:F().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:F().optional().describe(`User's timezone in IANA format.`),userAgent:F().optional().describe(`Host application identifier.`),platform:H([G(`web`),G(`desktop`),G(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:B({touch:L().optional().describe(`Whether the device supports touch input.`),hover:L().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:B({top:I().describe(`Top safe area inset in pixels.`),right:I().describe(`Right safe area inset in pixels.`),bottom:I().describe(`Bottom safe area inset in pixels.`),left:I().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),Gh=B({method:G(`ui/notifications/host-context-changed`),params:Wh.describe(`Partial context update containing only changed fields.`)});B({method:G(`ui/update-model-context`),params:B({content:z(Vu).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:U(F(),R().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),B({method:G(`ui/initialize`),params:B({appInfo:Pl.describe(`App identification (name and version).`),appCapabilities:Bh.describe(`Features and capabilities this app provides.`),protocolVersion:F().describe(`Protocol version this app supports.`)})});var Kh=B({protocolVersion:F().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Pl.describe(`Host application identification and version.`),hostCapabilities:zh.describe(`Features and capabilities provided by the host.`),hostContext:Wh.describe(`Rich context about the host environment.`)}).passthrough(),qh={target:`draft-2020-12`};async function Jh(e,t){let n=e[`~standard`];if(n.jsonSchema)return n.jsonSchema[t](qh);throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function Yh(e,t,n=``){let r=await e[`~standard`].validate(t);if(r.issues){let e=r.issues.map(e=>{let t=e.path?.map(e=>typeof e==`object`?e.key:e).join(`.`);return t?`${t}: ${e.message}`:e.message}).join(`; `);throw Error(n+e)}return r.value}function Xh(e,t){let n={...e,...t};return t.experimental!==void 0&&(n.experimental={...e.experimental,...t.experimental}),t.tools!==void 0&&(n.tools={...e.tools,...t.tools}),n}var Zh=class e extends Zm{_appInfo;_appCapabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_registeredEvents=new Set;_events=new gh;_methods=new _h;setRequestHandler=(...e)=>{let[t,...n]=yh(`request`,e)??e;this._methods.claim(t,`setRequestHandler`),super.setRequestHandler.call(this,t,...n)};setNotificationHandler=(...e)=>{let[t,...n]=yh(`notification`,e)??e;this._methods.claim(t,`setNotificationHandler`),super.setNotificationHandler.call(this,t,...n)};removeRequestHandler=e=>{this._methods.release(e),super.removeRequestHandler(e)};removeNotificationHandler=e=>{this._methods.release(e),super.removeNotificationHandler(e)};replaceRequestHandler=(e,...t)=>{this._methods.replace(e),super.setRequestHandler.call(this,e,...t)};_assertInitialized(e){if(this._initializedSent)return;let t=`[ext-apps] App.${e}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(t);console.warn(`${t}. This will throw in a future release.`)}eventSchemas={toolinput:jh,toolinputpartial:Mh,toolresult:Uh,toolcancelled:Nh,hostcontextchanged:Gh};static ONE_SHOT_EVENTS=new Set([`toolinput`,`toolinputpartial`,`toolresult`,`toolcancelled`]);_everHadListener=new Set;_assertHandlerTiming(t){if(!e.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(e,t){t&&this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.setHandler(e,t)}addEventListener(e,t){this._assertHandlerTiming(e),this._ensureEventSlot(e),this._events.addEventListener(e,t)}removeEventListener(e,t){this._events.removeEventListener(e,t)}_ensureEventSlot(e){if(this._registeredEvents.has(e))return;let t=this.eventSchemas[e];if(!t)throw Error(`Unknown event: ${String(e)}`);this.setNotificationHandler(t.shape.method.value,{params:t.shape.params},t=>{let n=t;e===`hostcontextchanged`&&(this._hostContext={...this._hostContext,...n}),this._events.dispatch(e,n)}),this._registeredEvents.add(e)}getEventHandler(e){return this._events.getHandler(e)}warnIfRequestHandlerReplaced(e,t,n){t&&n&&console.warn(`[MCP Apps] ${e} handler replaced. Previous handler will no longer be called.`)}constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._appCapabilities=t,this.options=n,this._methods.replace(`notifications/cancelled`),this._methods.replace(`notifications/progress`),!n.allowUnsafeEval&&Ye({jitless:!0}),this.replaceRequestHandler(`ping`,e=>(console.log(`Received ping:`,e.params),{})),this.setEventHandler(`hostcontextchanged`,void 0)}buildContext(e){return e}registerAppCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after transport is established`);this._appCapabilities=Xh(this._appCapabilities,e)}registerTool(e,t,n){if(this._registeredTools[e])throw Error(`Tool ${e} is already registered`);let r=this,i=()=>{r._initializedSent&&r._appCapabilities.tools?.listChanged&&r.sendToolListChanged()},a=t.inputSchema!==void 0,o={title:t.title,description:t.description,inputSchema:t.inputSchema,outputSchema:t.outputSchema,annotations:t.annotations,_meta:t._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(e){Object.assign(this,e),i()},remove(){r._registeredTools[e]===o&&(delete r._registeredTools[e],i())},handler:async(t,r)=>{if(!o.enabled)throw Error(`Tool ${e} is disabled`);let i;if(a){let a=o.inputSchema;i=await n(a?await Yh(a,t??{},`Invalid input for tool ${e}: `):t??{},r)}else i=await n(r);return o.outputSchema&&!i.isError&&(i.structuredContent=await Yh(o.outputSchema,i.structuredContent,`Invalid output for tool ${e}: `)),i}};return this._registeredTools[e]=o,!this._appCapabilities.tools&&!this.transport&&this.registerAppCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),o}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(e,t)=>{let n=this._registeredTools[e.name];if(!n)throw Error(`Tool ${e.name} not found`);return n.handler(e.arguments,t)},this.onlisttools=async(e,t)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([e,t])=>t.enabled).map(async([e,t])=>{let n={name:e,title:t.title,description:t.description,inputSchema:t.inputSchema?await Jh(t.inputSchema,`input`):{type:`object`,properties:{}}};return t.outputSchema&&(n.outputSchema=await Jh(t.outputSchema,`output`)),t.annotations&&(n.annotations=t.annotations),t._meta&&(n._meta=t._meta),n}))}))}async sendToolListChanged(e={}){this._assertInitialized(`sendToolListChanged`),await this.notification({method:`notifications/tools/list_changed`,params:e})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler(`toolinput`)}set ontoolinput(e){this.setEventHandler(`toolinput`,e)}get ontoolinputpartial(){return this.getEventHandler(`toolinputpartial`)}set ontoolinputpartial(e){this.setEventHandler(`toolinputpartial`,e)}get ontoolresult(){return this.getEventHandler(`toolresult`)}set ontoolresult(e){this.setEventHandler(`toolresult`,e)}get ontoolcancelled(){return this.getEventHandler(`toolcancelled`)}set ontoolcancelled(e){this.setEventHandler(`toolcancelled`,e)}get onhostcontextchanged(){return this.getEventHandler(`hostcontextchanged`)}set onhostcontextchanged(e){this.setEventHandler(`hostcontextchanged`,e)}_onteardown;get onteardown(){return this._onteardown}set onteardown(e){this.warnIfRequestHandlerReplaced(`onteardown`,this._onteardown,e),this._onteardown=e,this.replaceRequestHandler(`ui/resource-teardown`,{params:Ih.shape.params,result:Lh},(e,t)=>{if(!this._onteardown)throw Error(`No onteardown handler set`);return this._onteardown(e,t)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(e){this.warnIfRequestHandlerReplaced(`oncalltool`,this._oncalltool,e),this._oncalltool=e,this.replaceRequestHandler(`tools/call`,(e,t)=>{if(!this._oncalltool)throw Error(`No oncalltool handler set`);return this._oncalltool(e.params,t)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(e){this.warnIfRequestHandlerReplaced(`onlisttools`,this._onlisttools,e),this._onlisttools=e,this.replaceRequestHandler(`tools/list`,(e,t)=>{if(!this._onlisttools)throw Error(`No onlisttools handler set`);return this._onlisttools(e.params,t)})}assertCapabilityForMethod(e){if(e===`sampling/createMessage`&&!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${e})`)}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._appCapabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;default:return}}assertNotificationCapability(e){}async callServerTool(e,t){if(this._assertInitialized(`callServerTool`),typeof e==`string`)throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:`tools/call`,params:e},{onprogress:()=>{},resetTimeoutOnProgress:!0,...t})}async readServerResource(e,t){return this._assertInitialized(`readServerResource`),await this.request({method:`resources/read`,params:e},t)}async listServerResources(e,t){return this._assertInitialized(`listServerResources`),await this.request({method:`resources/list`,params:e},t)}async createSamplingMessage(e,t){return this._assertInitialized(`createSamplingMessage`),await this.request({method:`sampling/createMessage`,params:e},t)}sendMessage(e,t){return this._assertInitialized(`sendMessage`),this.request({method:`ui/message`,params:e},Oh,t)}sendLog(e){return this.notification({method:`notifications/message`,params:e})}updateModelContext(e,t){return this._assertInitialized(`updateModelContext`),this.request({method:`ui/update-model-context`,params:e},Ol,t)}openLink(e,t){return this._assertInitialized(`openLink`),this.request({method:`ui/open-link`,params:e},Eh,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this._assertInitialized(`downloadFile`),this.request({method:`ui/download-file`,params:e},Dh,t)}requestTeardown(e={}){return this.notification({method:`ui/notifications/request-teardown`,params:e})}requestDisplayMode(e,t){return this._assertInitialized(`requestDisplayMode`),this.request({method:`ui/request-display-mode`,params:e},Vh,t)}sendSizeChanged(e){return this.notification({method:`ui/notifications/size-changed`,params:e})}setupSizeChangedNotifications(){let e=!1,t=0,n=0,r=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let r=document.documentElement,i=r.style.height;r.style.height=`max-content`;let a=Math.ceil(r.getBoundingClientRect().height);r.style.height=i;let o=Math.ceil(window.innerWidth);(o!==t||a!==n)&&(t=o,n=a,this.sendSizeChanged({width:o,height:a}))}))};r();let i=new ResizeObserver(r);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(e=new Sh(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);this._initializedSent=!1;try{await super.connect(e);let n=await this.request({method:`ui/initialize`,params:{appCapabilities:this._appCapabilities,appInfo:this._appInfo,protocolVersion:xh}},Kh,t);if(n===void 0)throw Error(`Server sent invalid initialize result: ${n}`);this._hostCapabilities=n.hostCapabilities,this._hostInfo=n.hostInfo,this._hostContext=n.hostContext,await this.notification({method:`ui/notifications/initialized`}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(e){throw this.close(),e}}};function Qh(e){let t=new Date(e);return Number.isFinite(t.getTime())?`${t.toISOString().slice(0,19).replace(`T`,` `)} UTC`:typeof e==`number`?`${e} milliseconds since 1970-01-01T00:00:00Z`:e}function $h(e,t,n){let r=document.createElement(e);return t&&(r.className=t),n!==void 0&&(r.textContent=n),r}function eg(e,t,n=`primary`){let r=document.createElement(`button`);return r.type=`button`,r.className=n===`primary`?`ui-btn ui-btn--primary`:n===`danger`?`ui-btn ui-btn--danger`:`ui-btn`,r.textContent=e,r.addEventListener(`click`,t),r}function tg(e,t){let n=document.createElement(`a`);return n.className=`ui-link`,n.textContent=e,n.href=t,n}function ng(e){let t=document.createElement(`input`);return t.type=e.type??`text`,t.className=t.type===`checkbox`?`ui-checkbox`:`ui-input`,e.value!==void 0&&(t.value=e.value),e.placeholder!==void 0&&(t.placeholder=e.placeholder),e.id&&(t.id=e.id),e.name&&(t.name=e.name),t.autocomplete=`off`,t}function rg(e,t){let n=document.createElement(`label`),r=t.tagName===`INPUT`&&t.type===`checkbox`;n.className=r?`ui-field ui-field--check`:`ui-field`;let i=$h(`span`,void 0,e);return r?n.append(t,i):n.append(i,t),n}function ig(e){let t=document.createElement(`select`);t.className=`ui-select`;for(let n of e.choices){let r=document.createElement(`option`);r.value=n.value,r.textContent=n.label,e.value===n.value&&(r.selected=!0),t.append(r)}return e.id&&(t.id=e.id),e.name&&(t.name=e.name),e.onChange&&t.addEventListener(`change`,()=>e.onChange(t.value)),t}function ag(e,t=!1){let n=document.createElement(`details`);n.className=`ui-accordion`,n.open=t;let r=document.createElement(`summary`);r.className=`ui-accordion-summary`,r.append($h(`span`,void 0,e));let i=$h(`div`,`ui-accordion-body`);return n.append(r,i),{details:n,body:i}}function og(e){let t=$h(`time`,void 0,Qh(e));return t.dateTime=e,t.title=e,t.setAttribute(`aria-label`,e),t}var sg=/^(?!.*(^(?!@)|[-.@])($|[-.@]))(?:[a-z0-9-]{0,63}(?:\.[a-z0-9-]{0,63})*)?@[a-z0-9-]{0,63}$/i,cg=/^(?!.*(^|[-.])($|[-.]))(?:[a-z0-9-]{0,63}\.)+sui$/i,lg=235;function ug(e){return e.length>lg?!1:e.includes(`@`)?sg.test(e):cg.test(e)}var dg=/^([a-z0-9]+(?:-[a-z0-9]+)*)$/,fg=/^\d+$/,pg=64,mg=e=>{let t=e.split(`/`);if(t.length<2||t.length>3)return!1;let[n,r,i]=t;return i!==void 0&&!fg.test(i)||!ug(n)?!1:dg.test(r)&&r.length<pg},hg=e=>Object.freeze(e());function gg(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}function _g(e){if(!gg(e))throw TypeError(`Uint8Array expected`)}function vg(e,t){if(typeof t!=`string`)throw TypeError(`${e}: string expected`);return!0}var yg=(()=>{try{let e=new TextDecoder;return e.decode(Uint8Array.of(65,48,43,127))===`A0+`?e:void 0}catch{return}})(),bg=8192;function xg(e){let t=e.length;if(yg!==void 0&&t>=12)return yg.decode(e);if(t<=bg)return String.fromCharCode.apply(null,e);let n=``;for(let r=0;r<t;r+=bg)n+=String.fromCharCode.apply(null,e.subarray(r,r+bg));return n}function Sg(e,t){let n=e.length;if(n>128)throw Error(`alphabet: max 128 letters`);let r=new Uint8Array(n),i=new Int8Array(128).fill(-1);for(let t=0;t<n;t++){let n=e.charCodeAt(t);if(e.codePointAt(t)!==n||n>127)throw Error(`alphabet: single-char ASCII letters only`);r[t]=n,i[n]=t}if(t!==void 0)for(let e of Object.keys(t)){let n=e.charCodeAt(0),r=i[t[e].charCodeAt(0)];if(e.length!==1||n>127||r===void 0||r===-1)throw Error(`alphabet: invalid alias ${e}`);i[n]=r}return{encode:e=>{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++){let i=e[n],a=r[i];if(a===void 0)throw Error(`alphabet.encode: invalid digit ${i}`);t[n]=a}return xg(t)},decode:t=>{vg(`decode`,t);let n=t.length,r=new Uint8Array(n);for(let a=0;a<n;a++){let n=t.charCodeAt(a),o=n<128?i[n]:-1;if(o===-1)throw Error(`Unknown letter "${t[a]}". Allowed: ${e}`);r[a]=o}return r}}}var Cg=656356768,wg=65536,Tg=2048,Eg=4096,Dg=(e,t)=>({encode:n=>{_g(n);let r=n.length;if(r===0)return new Uint8Array;if(r>=wg)throw Error(`invalid length`);let i=0;for(;i<r-1&&n[i]===0;)i++;let a=Math.ceil(r/2),o=new Uint16Array(a),s=r&1;s&&(o[0]=n[0]);for(let e=s,t=s;e<r;e+=2,t++)o[t]=n[e]<<8|n[e+1];let c=[],l=0;for(;l<a;){let e=0;for(let n=l;n<a;n++){let r=e*65536+o[n],i=Math.floor(r/t);e=r-i*t,o[n]=i,i===0&&n===l&&l++}c.push(e)}let u=c.length-1,d=u*5;for(let t=c[u];d++,!(t<e);t=Math.floor(t/e));let f=new Uint8Array(i+d),p=f.length-1;for(let t=0;t<u;t++){let n=c[t];for(let t=0;t<5;t++)f[p--]=n%e,n=Math.floor(n/e)}for(let t=c[u];p>=i;t=Math.floor(t/e))f[p--]=t%e;return f},decode:t=>{_g(t);let n=t.length;if(n===0)return new Uint8Array;if(n>=wg)throw Error(`invalid length`);let r=0;for(;r<n-1&&t[r]===0;)r++;let i=new Uint16Array(Math.ceil(n*6/16)+1),a=0,o=0,s=n%5||5;for(;o<n;){let n=0,r=1;for(let i=o+s;o<i;o++){let i=t[o];if(i>=e)throw Error(`invalid integer: ${i}`);n=n*e+i,r*=e}s=5;let c=n;for(let e=0;e<a;e++){let t=i[e]*r+c;c=Math.floor(t/65536),i[e]=t-c*65536}for(;c>0;c=Math.floor(c/65536))i[a++]=c%65536}let c=a===0?1:a*2-(i[a-1]<256),l=new Uint8Array(r+c),u=l.length-1;for(let e=0;e<a;e++){let t=i[e];l[u--]=t&255,u>=r&&(l[u--]=t>>8)}return l}}),Og=(e,t)=>{let n=Sg(t);return{encode(t){if(_g(t),t.length>Tg)throw Error(`invalid length`);return n.encode(e.encode(t))},decode(t){if(vg(`baseN.decode`,t),t.length>Eg)throw Error(`invalid length`);return e.decode(n.decode(t))}}},kg=Dg(58,Cg),Ag=e=>Og(kg,e),jg=hg(()=>Ag(`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`)),Mg=e=>jg.decode(e);function Ng(e,t=[`<`,`>`]){let[n,r]=t,i=[],a=``,o=0;for(let t=0;t<e.length;t++){let s=e[t];s===n&&o++,s===r&&o--,o===0&&s===`,`?(i.push(a.trim()),a=``):a+=s}return i.push(a.trim()),i}var Pg=32;function Fg(e){try{return Mg(e).length===Pg}catch{return!1}}function Ig(e){return Vg(e)&&Hg(e)===32}function Lg(e){if(e.startsWith(`vector<`)){if(!e.endsWith(`>`))throw Error(`Invalid type tag: ${e}`);let t=e.slice(7,-1);if(!t)throw Error(`Invalid type tag: ${e}`);let n=Lg(t);return typeof n==`string`?`vector<${n}>`:`vector<${zg(n)}>`}return e.includes(`::`)?Rg(e):e}function Rg(e){let t=e.split(`::`);if(t.length<3)throw Error(`Invalid struct tag: ${e}`);let[n,r]=t;if(!n||!r)throw Error(`Invalid struct tag: ${e}`);let i=mg(n),a=e.slice(n.length+r.length+4),o=a.includes(`<`)?a.slice(0,a.indexOf(`<`)):a;if(!o||a.includes(`<`)&&!a.endsWith(`>`))throw Error(`Invalid struct tag: ${e}`);let s=a.includes(`<`)?Ng(a.slice(a.indexOf(`<`)+1,a.lastIndexOf(`>`))).map(e=>Lg(e.trim())):[];return{address:i?n:Bg(n),module:r,name:o,typeParams:s}}function zg(e){if(typeof e==`string`&&e.startsWith(`vector<`))throw Error(`normalizeStructTag does not support vector types. Use normalizeTypeTag instead.`);let{address:t,module:n,name:r,typeParams:i}=typeof e==`string`?Rg(e):e;return`${t}::${n}::${r}${i?.length>0?`<${i.map(e=>typeof e==`string`?e:zg(e)).join(`,`)}>`:``}`}function Bg(e,t=!1){let n=e.toLowerCase();return!t&&n.startsWith(`0x`)&&(n=n.slice(2)),`0x${n.padStart(64,`0`)}`}function Vg(e){return/^(0x|0X)?[a-fA-F0-9]+$/.test(e)&&e.length%2==0}function Hg(e){return/^(0x|0X)/.test(e)?(e.length-2)/2:e.length/2}function Ug(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}var Wg=e=>e?`"${e}" `:``;function Gg(e,t=``){if(typeof e!=`number`)throw TypeError(Wg(t)+`expected number, got `+typeof e);if(!Number.isSafeInteger(e)||e<0)throw RangeError(Wg(t)+`expected integer >= 0, got `+e);return e}function Kg(e,t,n=``){if(Ug(e)&&(t===void 0||e.length===t))return e;t!==void 0&&Gg(t,`length`);let r=Ug(e),i=t===void 0?``:` of length ${t}`,a=r?`length=${e.length}`:`type=${typeof e}`,o=Wg(n)+`expected Uint8Array`+i+`, got `+a;throw r?RangeError(o):TypeError(o)}var qg=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw TypeError((t===`object`?``:`"${t}" `)+`expected object, got type=`+typeof e)},Jg=(e,t)=>{qg(e,t);let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)throw TypeError(`"${t}" expected plain object`);if(Object.hasOwn(e,`__proto__`))throw TypeError(`"${t}.__proto__" is not allowed`)};function Yg(e,t=!0){if(e.destroyed)throw Error(`hash was destroyed`);if(t&&e.finished)throw Error(`digest() was already called`)}function Xg(e,t){Kg(e,void 0,`output`);let n=t.outputLen;if(!(e.length>=n))throw RangeError(`"output" expected length >= `+n)}function Zg(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function Qg(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function $g(e,t){return e<<32-t|e>>>t}function e_(e,t,n=`opts`){return Jg(e,`defaults`),t!==void 0&&Jg(t,n),Object.assign(Object.create(null),e,t)}function t_(e,t={}){if(typeof e!=`function`)throw TypeError(`"hashCons" expected function, got type=`+typeof e);t=e_({},t,`info`);let n=(t,n)=>e(n).update(t).digest(),r=e(void 0);return n.outputLen=r.outputLen,n.blockLen=r.blockLen,n.canXOF=r.canXOF,n.create=t=>e(t),Object.assign(n,t),Object.freeze(n)}var n_=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])}),r_=e=>e/2**32|0,i_=e=>e>>>0;function a_(e,t,n,r){let i=r_(n),a=i_(n);e.setUint32(t,r?a:i,r),e.setUint32(t+4,r?i:a,r)}function o_(e,t,n){return e&t^~e&n}function s_(e,t,n){return e&t^e&n^t&n}var c_=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,n,r){this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=Qg(this.buffer)}update(e){Yg(this),Kg(e);let{view:t,buffer:n,blockLen:r}=this,i=e.length,a=!1;for(let o=0;o<i;){let s=Math.min(r-this.pos,i-o);if(s===r){let t=Qg(e);for(;r<=i-o;o+=r)this.process(t,o);a=!0}else n.set(o===0&&s===i?e:e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0,a=!0)}return this.length+=e.length,a&&this.roundClean(),this}digestInto(e){Yg(this),Xg(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:r,isLE:i}=this,{pos:a}=this;t[a++]=128,t.fill(0,a),this.padOffset>r-a&&(this.process(n,0),t.fill(0)),a_(n,r-8,this.length*8,i),this.process(n,0),this.roundClean();let o=e===t?n:Qg(e),s=this.outputLen,c=s/4,l=this.get();if(s%4||c>l.length)throw Error(`invalid outputLen`);for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:t,length:n,finished:r,destroyed:i,pos:a}=this;return e.destroyed=i,e.finished=r,e.length=n,e.pos=a,a&&e.buffer.set(t),e}clone(){return this._cloneInto()}},l_=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),u_=`0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI`,d_=F().refine(Ig,`Expected a 32-byte Sui address`),f_=F().refine(Fg,`Expected a Sui transaction digest`),p_=d_.transform(e=>Bg(e));function m_(e){let t=p_.safeParse(e);return t.success?t.data:void 0}var h_=[`sui:mainnet`,`eip155:1`,`solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`],g_=h_[0],__=W(h_),v_=U(__,I().int().nonnegative()),y_=z(__).refine(e=>new Set(e).size===e.length,`Networks must be distinct`);function b_(e){let t=new Set(y_.parse(e));return h_.filter(e=>t.has(e))}function x_(e,t){if(e===g_)return m_(t);if(e===`eip155:1`)return/^0x[0-9a-fA-F]{40}$/.test(t)?t.toLowerCase():void 0;try{return Mg(t).length===32?t:void 0}catch{return}}var S_=B({chainId:__,address:F()}).strict().refine(e=>x_(e.chainId,e.address)===e.address,`Expected a normalized chain address`),C_=z(B({chainId:__,accounts:z(B({address:F(),displayAddress:F().optional(),methods:z(F()),events:z(F())}).strict()),invalidAccounts:G(!0).optional()}).strict().superRefine((e,t)=>{(new Set(e.accounts.map(e=>e.address)).size!==e.accounts.length||e.invalidAccounts&&e.accounts.length||e.accounts.some(t=>x_(e.chainId,t.address)!==t.address||t.displayAddress!==void 0&&x_(e.chainId,t.displayAddress)!==t.address))&&t.addIssue({code:`custom`,message:`Wallet grant accounts must match their chain`})})).refine(e=>new Set(e.map(e=>e.chainId)).size===e.length,`Wallet grants must have distinct chains`),w_=z(hc(`status`,[S_.safeExtend({status:G(`bound`)}).strict(),B({chainId:__,status:W([`not_approved`,`multiple_accounts`,`invalid_response`])}).strict()])).refine(e=>new Set(e.map(e=>e.chainId)).size===e.length,`One result per requested chain is required`);B({accounts:z(F()),methods:z(F()),events:z(F())});var T_=(1n<<64n)-1n,E_=/^(?:0|[1-9][0-9]*)$/,D_=/^(?:0|-?[1-9][0-9]*)$/;function O_(e,t,n={}){if(!/^\d+$/.test(e))throw Error(`${t} must be an unsigned integer string`);let r=BigInt(e);if(n.positive&&r===0n)throw Error(`${t} must be positive`);if(r>T_)throw Error(`${t} must fit u64`);return r}function k_(e){let t=e===`rawAmount`?`amount`:e;return F().min(1).refine(t=>{try{return O_(t,e),!0}catch{return!1}},`Expected a raw u64 ${t} string`)}function A_(e,t,n={}){if(!E_.test(e))throw Error(`${t} must be a canonical unsigned integer string`);return O_(e,t,n)}function j_(e){return F().min(1).refine(t=>{try{return A_(t,e),!0}catch{return!1}},`Expected an unsigned integer string`)}function M_(e,t){if(!D_.test(e))throw Error(`${t} must be a signed integer string`);return BigInt(e)}function N_(e){return F().min(1).refine(t=>{try{return M_(t,e),!0}catch{return!1}},`Expected a signed integer string`)}function P_(e){return zg(e)}var F_=[`transaction`,`effects`,`balanceChanges`,`objectTypes`],I_=F().refine(e=>{let t=new Date(e);return Number.isFinite(t.getTime())&&t.toISOString()===e},`Expected ISO 8601 UTC timestamp`),L_=z(W(F_)).length(F_.length).superRefine((e,t)=>{for(let n of F_)e.includes(n)||t.addIssue({code:`custom`,path:[],message:`chain receipt include is missing '${n}'`});new Set(e).size!==e.length&&t.addIssue({code:`custom`,path:[],message:`chain receipt include fields must not be duplicated`})}),R_=F().min(1).max(512).refine(e=>{try{return P_(e),!0}catch{return!1}},`Expected a Sui struct tag coin type`),z_=B({commandIndex:I().int().nonnegative(),packageId:d_,module:F().min(1).max(128),function:F().min(1).max(128),target:F().min(1).max(512)}).strict().superRefine((e,t)=>{let n=`${e.packageId}::${e.module}::${e.function}`;e.target!==n&&t.addIssue({code:`custom`,path:[`target`],message:`package call target must match packageId::module::function`})}),B_=B({index:I().int().nonnegative(),coinType:R_,amountRaw:N_(`accountBalanceChanges[].amountRaw`),direction:W([`increase`,`decrease`,`zero`])}).strict().superRefine((e,t)=>{let n=M_(e.amountRaw,`accountBalanceChanges[].amountRaw`),r=n>0n?`increase`:n<0n?`decrease`:`zero`;e.direction!==r&&t.addIssue({code:`custom`,path:[`direction`],message:`balance change direction must match amountRaw sign`})}),V_=hc(`success`,[B({success:G(!0),errorKind:uc().optional(),errorMessage:uc().optional()}).strict(),B({success:G(!1),errorKind:F().min(1).max(200).optional(),errorMessage:F().min(1).max(2e3).optional()}).strict()]),H_=B({kind:G(`sui_chain_receipt_v1`),source:B({method:G(`client.core.getTransaction`),network:G(`sui:mainnet`),chainIdentifier:F().min(1),fetchedAt:I_,include:L_}).strict(),txDigest:f_,sender:d_,effectsStatus:V_,packageCalls:z(z_),accountBalanceChanges:z(B_),objectTypes:U(d_,F().min(1).max(512))}).strict(),U_=W([`awaiting_signature`,`submitting`,`awaiting_chain_result`,`stopped`,`request_failed`,`outcome_unknown`,`completed`]),W_=B({reviewSessionId:F().min(1),attemptId:F().min(1),planId:F().min(1),status:W([`success`,`failure`]),txDigest:f_,chainReceipt:H_,failureReason:G(`chain_execution_failed`).optional(),recordedAt:F().datetime()}).strict().superRefine((e,t)=>{(e.txDigest!==e.chainReceipt.txDigest||e.status===`success`!==e.chainReceipt.effectsStatus.success)&&t.addIssue({code:`custom`,message:`Execution must match the observed chain receipt.`}),e.status===`failure`!=(e.failureReason!==void 0)&&t.addIssue({code:`custom`,message:`Only a chain failure has a chain execution failure reason.`})}),G_=B({attemptId:F().min(1),reviewSessionId:F().min(1),planId:F().min(1),reviewRevision:I().int().nonnegative(),account:d_,transactionDigest:f_,requestStatus:U_,revision:I().int().nonnegative(),createdAt:F().datetime(),updatedAt:F().datetime(),signatureVerifiedAt:F().datetime().optional(),submittedAt:F().datetime().optional(),reason:F().optional(),execution:W_.optional()}).strict().superRefine((e,t)=>{let n=e.execution;e.requestStatus===`completed`!=(n!==void 0)&&t.addIssue({code:`custom`,message:`Completed requests require an observed execution result.`}),n&&(n.attemptId!==e.attemptId||n.reviewSessionId!==e.reviewSessionId||n.planId!==e.planId||n.txDigest!==e.transactionDigest||n.chainReceipt.sender!==e.account)&&t.addIssue({code:`custom`,message:`Execution identity differs from the admitted request.`})}),K_=F().uuid(),q_=W([`process_start`,`sdk_start`,`session_restore`,`state_sync`]),J_=W([`initialization_failed`,`restoration_failed`,`wallet_state_unavailable`]),Y_=hc(`status`,[B({status:G(`available`),walletRunId:K_}).strict(),B({status:G(`initializing`),walletRunId:K_,stage:q_,message:F()}).strict(),B({status:G(`recovering`),walletRunId:K_,message:F()}).strict(),B({status:G(`unavailable`),walletRunId:K_.optional(),reason:J_,message:F()}).strict()]),X_=hc(`status`,[B({status:G(`idle`)}).strict(),B({status:G(`waiting`)}).strict(),B({status:G(`unavailable`),reason:G(`wallet_unavailable`),message:F()}).strict()]),Z_=W([`awaiting_approval`,`connected`,`rejected`,`failed`,`expired`,`stopped`,`disconnected`]);B({runId:F().uuid(),connections:z(B({connectionId:F().min(1),revision:I().int().nonnegative(),status:Z_,chainResults:w_,walletName:F().optional(),sdkPending:L(),disconnectPending:L()}).strict()),preparations:z(B({id:F().min(1),revision:I().int().nonnegative(),review_revision:I().int().nonnegative(),preparation_id:F().nullable(),wallet_connection_id:F().nullable()}).strict()),requests:z(B({attempt_id:F().min(1),revision:I().int().nonnegative(),request_status:U_,can_submit:I().int().min(0).max(1),sdk_pending:I().int().min(0).max(1),submit_pending:I().int().min(0).max(1),lookup_pending:I().int().min(0).max(1)}).strict())}).strict();var Q_=B({connectionId:F().min(1),status:Z_,revision:I().int().nonnegative(),requestedChains:y_,chainResults:w_,approvedAt:F().datetime().optional(),grants:C_,grantRevisions:v_,lifecycleRevision:I().int().nonnegative(),createdAt:F().datetime(),updatedAt:F().datetime(),expiresAt:F().datetime(),walletName:F().optional(),reason:F().optional()}).strict().superRefine((e,t)=>{(e.chainResults.some(t=>!e.requestedChains.includes(t.chainId))||e.approvedAt&&e.chainResults.length!==e.requestedChains.length||!e.approvedAt&&e.chainResults.length)&&t.addIssue({code:`custom`,message:`Approval results must match the exact requested networks.`})}),$_=B({chainId:__,status:W([`available`,`multiple_accounts`,`not_approved`,`invalid_response`,`unavailable`]),address:F().optional(),suiSigningScopeApproved:L(),reason:F().optional()}).strict(),ev=hc(`status`,[B({status:G(`available`),account:F()}).strict(),B({status:G(`address_required`),reason:G(`read_address_cleared`).optional()}).strict()]),tv=[`connect`,`disconnect`,`stop_connection`,`prepare_review`,`request_signature`,`cancel`,`stop_waiting`,`read_result`],nv=[`none`,`wait`,`check_status`,`open_settings`,`request_disconnect`,`request_review`],rv=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),iv=new Uint32Array(64),av=class extends c_{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(e,t){super(64,e,8,!1),this.A=t[0]|0,this.B=t[1]|0,this.C=t[2]|0,this.D=t[3]|0,this.E=t[4]|0,this.F=t[5]|0,this.G=t[6]|0,this.H=t[7]|0}get(){let{A:e,B:t,C:n,D:r,E:i,F:a,G:o,H:s}=this;return[e,t,n,r,i,a,o,s]}set(e,t,n,r,i,a,o,s){this.A=e|0,this.B=t|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=a|0,this.G=o|0,this.H=s|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,t){for(let n=0;n<16;n++,t+=4)iv[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=iv[e-15],n=iv[e-2],r=$g(t,7)^$g(t,18)^t>>>3,i=$g(n,17)^$g(n,19)^n>>>10;iv[e]=i+iv[e-7]+r+iv[e-16]|0}let{A:n,B:r,C:i,D:a,E:o,F:s,G:c,H:l}=this;for(let e=0;e<64;e++){let t=$g(o,6)^$g(o,11)^$g(o,25),u=l+t+o_(o,s,c)+rv[e]+iv[e]|0,d=($g(n,2)^$g(n,13)^$g(n,22))+s_(n,r,i)|0;l=c,c=s,s=o,o=a+u|0,a=i,i=r,r=n,n=u+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,a=a+this.D|0,o=o+this.E|0,s=s+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,a,o,s,c,l)}roundClean(){Zg(iv)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),Zg(this.buffer)}},ov=class extends av{constructor(){super(32,l_)}},sv=t_(()=>new ov,n_(1));function cv(e){for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n>=55296&&n<=56319){if(t+1>=e.length)return!1;let n=e.charCodeAt(++t);if(n<56320||n>57343)return!1}else if(n>=56320&&n<=57343)return!1}return!0}function lv(e){if(typeof e!=`string`)throw TypeError(`invalid mnemonic type: `+typeof e);if(!cv(e))throw TypeError(`expected well-formed Unicode string`);return e.normalize(`NFKD`)}function uv(e){let t=lv(e),n=t.split(` `);if(![12,15,18,21,24].includes(n.length))throw Error(`Invalid mnemonic`);return{nfkd:t,words:n}}function dv(e){if(Kg(e),![16,20,24,28,32].includes(e.length))throw RangeError(`invalid entropy length`)}var fv=e=>{let t=8-e.length/4;return sv(e)[0]>>t<<t};function pv(e){if(!Array.isArray(e)||e.length!==2048||typeof e[0]!=`string`)throw TypeError(`Wordlist: expected array of 2048 strings`);e.forEach(e=>{if(typeof e!=`string`)throw TypeError(`wordlist: non-string element: `+e);if(!cv(e))throw TypeError(`wordlist: expected well-formed Unicode string`)})}function mv(e,t){pv(t);let n=e.length/3*4,r=new Uint8Array(n+1),i=0,a=0,o=0;for(let n of e){let e=t.indexOf(n);if(e===-1)throw Error(`Unknown word: `+n);for(i=i<<11|e,a+=11;a>=8;)a-=8,r[o++]=i>>>a&255;i&=(1<<a)-1}a>0&&(r[o]=i<<8-a);let s=r.subarray(0,n);if(r[n]!==fv(s))throw Error(`Invalid checksum`);return Uint8Array.from(s)}function hv(e,t){let{words:n}=uv(e),r=mv(n,t);return dv(r),r}function gv(e,t){try{hv(e,t)}catch{return!1}return!0}var _v=Object.freeze(`abandon
1765
1765
  ability
1766
1766
  able
1767
1767
  about
@@ -3809,4 +3809,4 @@ zebra
3809
3809
  zero
3810
3810
  zone
3811
3811
  zoo`.split(`
3812
- `)),ov={0:`ED25519`,1:`Secp256k1`,2:`Secp256r1`,3:`MultiSig`,5:`ZkLogin`,6:`Passkey`},sv=e=>Object.freeze(e());function cv(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}function lv(e){if(!cv(e))throw TypeError(`Uint8Array expected`)}function uv(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(e=>typeof e==`string`):t.every(e=>Number.isSafeInteger(e)):!1}function dv(e){if(typeof e!=`function`)throw TypeError(`function expected`);return!0}function fv(e,t){if(typeof t!=`string`)throw TypeError(`${e}: string expected`);return!0}function pv(e,t=`number`){if(typeof e!=`number`)throw TypeError(`${t}: expected number, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`${t}: expected safe integer, got ${e}`)}function mv(e,t){if(!uv(!1,t))throw TypeError(`${e}: array of numbers expected`)}var hv=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function gv(e,t=e.length){let n=Array(t);for(let r=0;r<t;r++)n[r]=e[r];return n}var _v=(()=>{try{let e=new TextDecoder;return e.decode(Uint8Array.of(65,48,43,127))===`A0+`?e:void 0}catch{return}})(),vv=8192;function yv(e){let t=e.length;if(_v!==void 0&&t>=12)return _v.decode(e);if(t<=vv)return String.fromCharCode.apply(null,e);let n=``;for(let r=0;r<t;r+=vv)n+=String.fromCharCode.apply(null,e.subarray(r,r+vv));return n}function bv(e){if(pv(e),e<=0||e>8)throw RangeError(`radix2: bits should be in (0..8]`);let t=hv[e]-1;return{encode:n=>{lv(n);let r=n.length,i=new Uint8Array(Math.ceil(r*8/e)),a=0,o=0,s=0;for(let c=0;c<r;)for(c+2<r?(a=a<<24|n[c]<<16|n[c+1]<<8|n[c+2],o+=24,c+=3):(a=(a<<8|n[c])&65535,o+=8,c++);o-=e,i[s++]=a>>o&t,!(o<e););return o>0&&(i[s]=a<<e-o&t),i},decode:t=>{let n=t.length,r=new Uint8Array(Math.floor(n*e/8)),i=0,a=0,o=0;for(let s=0;s<n;s++)for(i=(i<<e|t[s])&65535,a+=e;a>=8;a-=8)r[o++]=i>>a-8&255;if(i=i<<8-a&255,a>=e)throw Error(`Excess padding`);if(i>0)throw Error(`Non-zero padding: ${i}`);return r}}}function xv(e,t){let n=e.length;if(n>128)throw Error(`alphabet: max 128 letters`);let r=new Uint8Array(n),i=new Int8Array(128).fill(-1);for(let t=0;t<n;t++){let n=e.charCodeAt(t);if(e.codePointAt(t)!==n||n>127)throw Error(`alphabet: single-char ASCII letters only`);r[t]=n,i[n]=t}if(t!==void 0)for(let e of Object.keys(t)){let n=e.charCodeAt(0),r=i[t[e].charCodeAt(0)];if(e.length!==1||n>127||r===void 0||r===-1)throw Error(`alphabet: invalid alias ${e}`);i[n]=r}return{encode:e=>{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++){let i=e[n],a=r[i];if(a===void 0)throw Error(`alphabet.encode: invalid digit ${i}`);t[n]=a}return yv(t)},decode:t=>{fv(`decode`,t);let n=t.length,r=new Uint8Array(n);for(let a=0;a<n;a++){let n=t.charCodeAt(a),o=n<128?i[n]:-1;if(o===-1)throw Error(`Unknown letter "${t[a]}". Allowed: ${e}`);r[a]=o}return r}}}function Sv(e){return dv(e),function(...t){try{return e.apply(null,t)}catch{}}}var Cv=xv(`qpzry9x8gf2tvdw0s3jn54khce6mua7l`),wv=/^[\x21-\x60\x7b-\x7e]+$/;function Tv(e,t){for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);if(r<33||r>126)throw Error(`${e}: printable ASCII expected`)}}function Ev(e){let t=e.length,n=new Uint8Array(t);for(let r=0;r<t;r++){let t=e[r];if(t<0||t>=32)throw Error(`alphabet.encode: invalid digit ${t}`);n[r]=t}return n}var Dv=[996825010,642813549,513874426,1027748829,705979059];function Ov(e){let t=e>>25,n=(e&33554431)<<5;for(let e=0;e<Dv.length;e++)(t>>e&1)==1&&(n^=Dv[e]);return n}function kv(e,t,n=1){let r=e.length,i=1;for(let t=0;t<r;t++){let n=e.charCodeAt(t);if(n<33||n>126)throw Error(`Invalid prefix (${e})`);i=Ov(i)^n>>5}i=Ov(i);for(let t=0;t<r;t++)i=Ov(i)^e.charCodeAt(t)&31;for(let e of t)i=Ov(i)^e;for(let e=0;e<6;e++)i=Ov(i);i^=n;let a=new Uint8Array(6);for(let e=0;e<6;e++)a[e]=i>>>5*(5-e)&31;return Cv.encode(a)}function Av(e){let t=e===`bech32`?1:734539939,n=bv(5),r=e=>{lv(e);let t=e.length,n=Array(Math.ceil(t*8/5)),r=0,i=0,a=0;for(let o=0;o<t;o++)for(r=r<<8|e[o],i+=8;i>=5;i-=5)n[a++]=r>>i-5&31;return i>0&&(n[a]=r<<5-i&31),n},i=e=>{mv(`radix2.decode`,e);let t=e.length,r=new Uint8Array(t);for(let n=0;n<t;n++){let t=e[n];if(t<0||t>=32)throw Error(`convertRadix2: invalid word=${t}`);r[n]=t}return n.decode(r)},a=Sv(i);function o(e,n,r=90){fv(`bech32.encode prefix`,e),r!==!1&&pv(r,`limit`),cv(n)&&(n=gv(n)),mv(`bech32.encode`,n);let i=e.length;if(i===0)throw TypeError(`Invalid prefix length ${i}`);let a=i+7+n.length;if(r!==!1&&a>r)throw TypeError(`Length ${a} exceeds limit ${r}`);Tv(`bech32.encode prefix`,e);let o=e.toLowerCase(),s=kv(o,n,t);return`${o}1${Cv.encode(Ev(n))}${s}`}function s(e,n=90){fv(`bech32.decode input`,e),n!==!1&&pv(n,`limit`);let r=e.length;if(r<8||n!==!1&&r>n)throw TypeError(`invalid string length ${r}, expected (8..${n})`);let i=e.toLowerCase();if(e!==i&&!wv.test(e))throw Tv(`bech32.decode input`,e),Error(`mixed-case string not allowed`);let a=i.lastIndexOf(`1`);if(a===0||a===-1)throw Error(`invalid separator "1"`);let o=i.slice(0,a),s=i.slice(a+1);if(s.length<6)throw Error(`invalid data length`);let c=Cv.decode(s),l=gv(c,c.length-6),u=kv(o,l,t);if(!s.endsWith(u))throw Error(`Invalid checksum in ${e}`);return{prefix:o,words:l}}let c=Sv(s);function l(e,t=90){let{prefix:n,words:r}=s(e,t);return{prefix:n,words:r,bytes:i(r)}}function u(e,t){return o(e,r(t))}return{encode:o,decode:s,encodeFromBytes:u,decodeToBytes:l,decodeUnsafe:c,fromWords:i,fromWordsUnsafe:a,toWords:r}}var jv=sv(()=>Av(`bech32`));function Mv(e){let{prefix:t,words:n}=jv.decode(e);if(t!==`suiprivkey`)throw Error(`invalid private key prefix`);let r=new Uint8Array(jv.fromWords(n)),i=r.slice(1);return{scheme:ov[r[0]],secretKey:i}}var Nv=`external-proposal-alpha-2026-05-25`,Pv=`proposal-review-model-alpha-2026-05-25`,Fv=F().refine(e=>{let t=new Date(e);return!Number.isNaN(t.getTime())&&t.toISOString()===e},`Expected ISO 8601 UTC timestamp`),Iv=/transaction\s*bytes?|transactionBytes|tx\s*bytes?|serialized\s*transaction|serializedTransaction|signed\s*transaction|signing\s*request|signingRequest|wallet\s*authorization|walletAuthorization|private\s*key|privateKey|secret\s*key|secretKey|seed\s*phrase|mnemonic|suiprivkey|signature|route[-_\s]*selected|routeSelectedPlan|bcs\s*transaction|programmable\s*transaction/i,Lv=/(?:0x[0-9a-fA-F]{160,}|[A-Za-z0-9+/_=-]{160,})/,Rv=/suiprivkey1[023456789acdefghjklmnpqrstuvwxyz]+/gi,zv=/(^|[^0-9a-fA-F])(?:0x)?[0-9a-fA-F]{64}($|[^0-9a-fA-F])/,Bv=/(^|[^A-Za-z0-9+/_=-])(?:[A-Za-z0-9+/]{43}=|[A-Za-z0-9+/]{44}|[A-Za-z0-9_-]{43,44})($|[^A-Za-z0-9+/_=-])/,Vv=/^(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$/,Hv=[12,15,18,21,24];function Uv(e,t,n={}){return F().min(1).max(e).superRefine((e,r)=>{(Iv.test(e)||Lv.test(e)||Gv(e)||Kv(e)||!n.allowRawSecretLikeText&&qv(e))&&r.addIssue({code:`custom`,message:`${t} must not contain executable, signing, private-key, mnemonic, route-selected, or encoded secret-like material`})})}function Wv(e,t){return Uv(e,t,{allowRawSecretLikeText:!0})}function Gv(e){return(e.match(Rv)??[]).some(e=>{try{return Mv(e.toLowerCase()),!0}catch{return e.toLowerCase().startsWith(`suiprivkey1`)}})}function Kv(e){let t=e.normalize(`NFKD`).toLowerCase().replace(/[^a-z]+/g,` `).trim().split(/\s+/).filter(Boolean);for(let e of Hv)if(!(t.length<e)){for(let n=0;n<=t.length-e;n+=1)if(iv(t.slice(n,n+e).join(` `),av))return!0}return!1}function qv(e){return zv.test(e)||Bv.test(e)}var Jv=Uv(80,`amountDisplay`).refine(e=>Vv.test(e)&&/[1-9]/.test(e),{message:`Expected a positive decimal display amount`}),Yv=B({kind:W([`mcp_server`,`ai_client`,`user`,`other`]),name:Uv(120,`source.name`),reference:Uv(256,`source.reference`).optional()}).strict(),Xv=B({address:d_.optional(),label:Uv(120,`party.label`).optional()}).strict().refine(e=>e.address!==void 0||e.label!==void 0,{message:`Expected address or label`}),Zv=B({amountDisplay:Jv,amountKind:G(`display_proposal`).default(`display_proposal`),symbol:Uv(64,`amount.symbol`).optional(),coinType:Wv(512,`amount.coinType`).optional(),denomination:Uv(64,`amount.denomination`).optional()}).strict(),Qv=B({packageId:Wv(128,`action.target.packageId`).optional(),module:Uv(128,`action.target.module`).optional(),function:Uv(128,`action.target.function`).optional(),objectId:Wv(128,`action.target.objectId`).optional(),label:Uv(120,`action.target.label`).optional()}).strict().refine(e=>e.packageId!==void 0||e.module!==void 0||e.function!==void 0||e.objectId!==void 0||e.label!==void 0,{message:`Expected at least one action target field`}),$v=B({direction:W([`outgoing`,`expected_incoming`,`fee`]),amount:Zv,recipient:Xv.optional(),description:Uv(512,`assetFlow.description`).optional()}).strict(),ey=B({id:Uv(120,`proposal.id`),source:Yv,network:G(`sui:mainnet`),createdAt:Fv,expiresAt:Fv.optional(),purpose:Uv(512,`purpose`),assumptions:z(Uv(512,`assumptions[]`)).max(20).optional(),requiredUserChoices:z(Uv(512,`requiredUserChoices[]`)).max(20).optional()}).strict(),ty=hc(`type`,[ey.extend({type:G(`payment`),payment:B({amount:Zv,recipient:Xv,target:Uv(512,`payment.target`).optional()}).strict()}).strict(),ey.extend({type:G(`sui_action`),action:B({actionKind:Uv(120,`action.actionKind`),target:Qv,recipient:Xv.optional(),assetFlow:z($v).max(20).optional()}).strict()}).strict()]),ny=B({id:F(),label:F(),status:W([`pass`,`warning`,`fail`]),message:F(),source:W([`proposal`,`adapter`,`registry`,`quote`,`wallet`,`simulation`,`network`])}).strict(),ry=B({id:F(),label:F(),reason:F()}).strict(),iy=B({modelVersion:G(Pv),contractVersion:G(Nv),proposalId:F(),proposalType:W([`payment`,`sui_action`]),proposalSource:Yv,proposedAction:B({kind:W([`payment`,`sui_action`]),title:F(),purpose:F(),network:G(`sui:mainnet`),recipient:Xv.optional(),target:H([F(),Qv]).optional()}).strict(),assetFlow:B({outgoing:z(Zv),expectedIncoming:z(Zv),fees:z(Zv)}).strict(),recipients:z(Xv),targets:z(H([F(),Qv])),evidenceUsed:z(B({id:F(),label:F(),source:W([`external_proposal`,`local_schema`]),summary:F()}).strict()),missingEvidence:z(ry),requiredUserChoices:z(ry),unsupportedClaims:z(B({id:F(),label:F(),reason:F()}).strict()),rejectedExecutableFields:z(B({fieldName:F(),reason:F()}).strict()),freshness:B({proposalCreatedAt:Fv,proposalExpiresAt:Fv.optional(),evaluatedAt:Fv,status:W([`current`,`expired`,`created_in_future`,`expiry_not_provided`]),reason:F()}).strict(),blockingChecks:z(ny),nonSignableReason:B({code:G(`external_proposal_review_only`),message:F(),blockedCapabilities:z(F())}).strict()}).strict();B({requestedIntent:ty,implementationStatus:G(`read_only_review_only`),contractVersion:G(Nv)}).strict();var ay=[`adapter_not_implemented`,`producer_stage_missing`,`wallet_review_contract_emit_missing`,`network_mismatch`,`insufficient_balance`,`insufficient_gas`,`allowlist_violation`,`asset_mismatch`,`amount_mismatch`,`wallet_mismatch`,`unsupported_action`,`object_resolution_failed`,`proposal_review_only`],oy=[`review_evidence_stale`,`quote_stale`,`quote_unavailable`,`simulation_transient_failure`,`review_update_failed`,`wallet_connection_changed`],sy=[`proposed`,`awaiting_wallet`,`wallet_connected`,`ready_for_wallet_review`,`refresh_required`,`blocked`,`expired`],cy=[`humanReadableReview`,`simulation`,`transactionReviewData`,`ptbVisualization`,`assetFlowActual`,`beforeAfterBalance`],ly=W([`client.core.simulateTransaction`,`client.transactionExecutionService.simulateTransaction`]),uy=`ptb-visualization-contract-alpha-2026-05-25`,dy=[`proposedAction`,`assetFlow`,`recipients`,`targets`,`evidenceUsed`,`missingEvidence`,`requiredUserChoices`,`unsupportedClaims`,`freshness`,`blockingChecks`],fy=[`effects`,`balanceChanges`,`objectTypes`,`transaction`],py=[`transaction_bytes`,`serialized_transaction`,`wallet_signature_request`,`private_key_material`,`wallet_authorization`,`signing_data`,`signing_readiness`,`payment_execution_readiness`],my=[`transaction_building_input`,`wallet_authorization`,`signing_data`,`signing_readiness`,`payment_execution_readiness`,`route_recommendation`],hy=u_,gy=`MIST`,_y=[`checkedAt`,`expiresAt`],vy=[`checkedAt`,`expiryStatus`],yy=[`rawAmount`,`asset`,`amountRole`],by=[`minOutRaw`,`asset`,`amountRole`],xy=[`gasBudgetRaw`,`asset`,`amountRole`],Sy=[`gasUsedRaw`,`asset`,`amountRole`],Cy=[`checkedAt`,`gasResolutionStatus`,`unresolvedReason`],wy=[`balanceChanges`,`asset`,`amountRole`],Ty=[`coinType`,`decimals`],Ey=[`quoteEvidenceId`,`minOutRaw`],Dy=[`maxSlippageBps`,`userSelection`],Oy=[`maxSlippageBps`,`minOutRaw`],ky=[`ownerAccount`,`objects`],Ay=[`pinned_sdk_registry`,`verified_mainnet_onchain_metadata`,`wallet_account_read`,`quote_evidence`,`review_time_simulation`,`validated_request_fact`,`user_explicit_choice`],jy=[`input`,`expected_output`,`minimum_output`,`gas_budget`,`gas_used`,`fee`,`balance_delta`],My={input:{kinds:[`validated_request_fact`,`wallet_account_read`,`user_explicit_choice`],fields:yy},expected_output:{kinds:[`quote_evidence`,`review_time_simulation`],fields:yy},minimum_output:{kinds:[`quote_evidence`],fields:by},gas_budget:{kinds:[`review_time_simulation`],fields:xy},gas_used:{kinds:[`review_time_simulation`],fields:Sy},fee:{kinds:[`review_time_simulation`],fields:yy},balance_delta:{kinds:[`review_time_simulation`],fields:wy}},Ny={pinned_sdk_metadata:{kinds:[`pinned_sdk_registry`],fields:Ty},verified_mainnet_onchain_metadata:{kinds:[`verified_mainnet_onchain_metadata`],fields:Ty}},Py={user_explicit:{kinds:[`user_explicit_choice`],fields:Dy},adapter_policy_from_quote_evidence:{kinds:[`quote_evidence`],fields:Oy}},Fy={kinds:[`review_time_simulation`],fields:Cy},Iy={kinds:[`quote_evidence`],fields:Ey},Ly={kinds:[`validated_request_fact`],fields:_y},Ry={kinds:[`validated_request_fact`],fields:vy},zy={raw_quantity_amount:{byRole:My},unit_metadata:{bySource:Ny},gas_unresolved_status:Fy,expiry_status:{current:Ly,expired:Ly,not_provided:Ry,not_applicable:Ry},quote_min_out:Iy,slippage_policy:{bySource:Py},object_ownership:{kinds:[`wallet_account_read`],fields:ky},simulation_result:{kinds:[`review_time_simulation`],fields:fy}},By={gasBudgetClaimId:{factKind:`raw_quantity_amount`,role:`gas_budget`,assetCoinType:hy,rawUnit:gy},gasUsedClaimId:{factKind:`raw_quantity_amount`,role:`gas_used`,assetCoinType:hy,rawUnit:gy},gasObjectOwnershipClaimId:{factKind:`object_ownership`,ownership:`owned_by_account`}},Vy=F().refine(e=>{let t=new Date(e);return!Number.isNaN(t.getTime())&&t.toISOString()===e},`Expected ISO 8601 UTC timestamp`),Hy=y_(`unsigned integer`),Uy=F().regex(/^0x[0-9a-fA-F]{1,64}$/,{message:`Expected a Sui object id`}),Wy=F().min(1).max(512).refine(e=>{try{return S_(e)===e}catch{return!1}},`Expected a normalized Sui struct tag coin type`),J=F().min(1).max(120),Gy=B({symbol:F().min(1).max(64).optional(),coinType:Wy}).strict(),Ky=/transaction\s*bytes?|tx\s*bytes?|serialized\s*transaction|serializedTransaction|signed\s*transaction|signing\s*request|signingRequest|wallet\s*authorization|walletAuthorization|private\s*key|privateKey|secret\s*key|secretKey|seed\s*phrase|mnemonic|suiprivkey|signature|bcs\s*transaction/i,qy=/(?:0x[0-9a-fA-F]{160,}|[A-Za-z0-9+/_=-]{160,})/;function Jy(e,t){return F().min(1).max(e).superRefine((e,n)=>{(Ky.test(e)||qy.test(e))&&n.addIssue({code:`custom`,message:`${t} must not contain executable transaction, signing, private-key, mnemonic, or long encoded material`})})}function Yy(e,t){let n=new Set(e);return t.filter(e=>!n.has(e))}function Xy(e,t,n,r,i){let a=Yy(t,n);a.length!==0&&e.addIssue({code:`custom`,path:r,message:`${i} must include ${a.join(`, `)}`})}function Zy(e,t,n,r,i){Xy(e,t,n,r,i)}function Qy(e,t,n){e.addIssue({code:`custom`,path:t,message:`${n} must match referenced evidence claim`})}function Y(e,t,n,r,i){t!==n&&Qy(e,r,i)}function $y(e,t,n,r,i){let a=new Set(t),o=new Set(n);if(a.size!==o.size)Qy(e,r,i);else for(let t of a)if(!o.has(t)){Qy(e,r,i);return}}function eb(e,t,n,r,i){(t.symbol!==n.symbol||t.coinType!==n.coinType)&&Qy(e,r,i)}function tb(e,t,n,r,i){try{S_(t.coinType)!==n&&Qy(e,r,i)}catch{Qy(e,r,i)}}var nb=B({kind:W([`natural_language_intent`,`external_proposal`,`mcp_action_request`,`local_review_request`]),sourceId:F().min(1).max(160),capturedAt:Vy,authority:G(`untrusted_until_review_regenerates_and_verifies`),userSelectionSource:W([`user_explicit`,`prior_user_explicit_context`]).optional()}).strict(),rb=B({id:J,kind:W(Ay),network:G(`sui:mainnet`),source:F().min(1).max(240),verifiedAt:Vy,fields:z(F().min(1).max(120)).min(1)}).strict(),ib=hc(`factKind`,[B({id:J,factKind:G(`raw_quantity_amount`),sourceEvidenceId:J,role:W(jy),asset:Gy,rawAmount:Hy}).strict(),B({id:J,factKind:G(`unit_metadata`),sourceEvidenceId:J,source:W([`pinned_sdk_metadata`,`verified_mainnet_onchain_metadata`]),coinType:Wy,decimals:I().int().min(0).max(255)}).strict(),B({id:J,factKind:G(`gas_unresolved_status`),sourceEvidenceId:J,checkedAt:Vy,status:G(`unresolved`),reason:F().min(1).max(240)}).strict(),B({id:J,factKind:G(`expiry_status`),sourceEvidenceId:J,checkedAt:Vy,status:W([`current`,`expired`,`not_provided`,`not_applicable`]),expiresAt:Vy.optional(),reason:F().min(1).max(240).optional()}).strict(),B({id:J,factKind:G(`quote_min_out`),sourceEvidenceId:J,quoteEvidenceId:F().min(1).max(120),minOutRaw:Hy}).strict(),B({id:J,factKind:G(`slippage_policy`),sourceEvidenceId:J,policySource:W([`user_explicit`,`adapter_policy_from_quote_evidence`]),maxSlippageBps:I().int().min(0).max(1e4),minOutRaw:Hy.optional()}).strict(),B({id:J,factKind:G(`object_ownership`),sourceEvidenceId:J,objectId:Uy,ownerAccount:d_,ownership:W([`owned_by_account`,`shared_object`,`immutable_or_package`,`not_owned_by_account`])}).strict(),B({id:J,factKind:G(`simulation_result`),sourceEvidenceId:J,provider:ly,checksEnabled:G(!0),simulatedAt:Vy,status:W([`success`,`failed`,`unavailable`]),requiredFields:z(W(fy)).min(fy.length),missingFields:z(W(fy)).default([]),failureReason:F().min(1).max(240).optional()}).strict()]),ab=B({id:J,role:W(jy),asset:Gy,rawAmount:Hy,unit:B({decimals:I().int().min(0).max(255),source:W([`pinned_sdk_metadata`,`verified_mainnet_onchain_metadata`]),sourceField:F().min(1).max(160),unitClaimId:J}).strict(),amountClaimId:J,displayOnly:B({amountDisplay:F().min(1).max(120),reason:G(`presentation_only_not_signing_input`)}).strict().optional()}).strict(),ob=B({objectId:Uy,ownerAccount:d_,ownershipClaimId:J}).strict(),sb=B({source:G(`review_time_simulation`),checkedAt:Vy,gasBudgetRaw:Hy.optional(),gasBudgetClaimId:J.optional(),gasUsedRaw:Hy.optional(),gasUsedClaimId:J.optional(),gasObjects:z(ob).optional(),unresolvedReason:F().min(1).max(240).optional(),unresolvedClaimId:J.optional()}).strict().superRefine((e,t)=>{let n=e.gasBudgetRaw!==void 0||e.gasUsedRaw!==void 0;!n&&e.unresolvedReason===void 0&&t.addIssue({code:`custom`,message:`Expected gas evidence or unresolvedReason`}),n&&e.unresolvedReason!==void 0&&t.addIssue({code:`custom`,path:[`unresolvedReason`],message:`Resolved gas quantities must not include unresolvedReason`}),e.gasBudgetRaw!==void 0&&e.gasBudgetClaimId===void 0&&t.addIssue({code:`custom`,path:[`gasBudgetClaimId`],message:`gasBudgetRaw requires gasBudgetClaimId`}),e.gasBudgetRaw===void 0&&e.gasBudgetClaimId!==void 0&&t.addIssue({code:`custom`,path:[`gasBudgetClaimId`],message:`gasBudgetClaimId requires gasBudgetRaw`}),e.gasUsedRaw!==void 0&&e.gasUsedClaimId===void 0&&t.addIssue({code:`custom`,path:[`gasUsedClaimId`],message:`gasUsedRaw requires gasUsedClaimId`}),e.gasUsedRaw===void 0&&e.gasUsedClaimId!==void 0&&t.addIssue({code:`custom`,path:[`gasUsedClaimId`],message:`gasUsedClaimId requires gasUsedRaw`}),e.unresolvedReason!==void 0&&e.unresolvedClaimId===void 0&&t.addIssue({code:`custom`,path:[`unresolvedClaimId`],message:`unresolvedReason requires unresolvedClaimId`}),e.unresolvedReason===void 0&&e.unresolvedClaimId!==void 0&&t.addIssue({code:`custom`,path:[`unresolvedClaimId`],message:`unresolvedClaimId requires unresolvedReason`})}),cb=hc(`status`,[B({checkedAt:Vy,status:G(`current`),expiresAt:Vy,evidenceClaimId:J}).strict(),B({checkedAt:Vy,status:G(`expired`),expiresAt:Vy,evidenceClaimId:J}).strict(),B({checkedAt:Vy,status:G(`not_provided`),evidenceClaimId:J,reason:F().min(1).max(240),expiresAt:uc().optional()}).strict(),B({checkedAt:Vy,status:G(`not_applicable`),evidenceClaimId:J,reason:F().min(1).max(240),expiresAt:uc().optional()}).strict()]).superRefine((e,t)=>{e.status===`current`&&Date.parse(e.expiresAt)<=Date.parse(e.checkedAt)&&t.addIssue({code:`custom`,path:[`expiresAt`],message:`Current expiry evidence requires expiresAt after checkedAt`}),e.status===`expired`&&Date.parse(e.expiresAt)>Date.parse(e.checkedAt)&&t.addIssue({code:`custom`,path:[`expiresAt`],message:`Expired expiry evidence requires expiresAt at or before checkedAt`})}),lb=B({status:W([`required_and_verified`,`not_required_for_action`,`missing`,`stale`]),quoteEvidenceId:F().min(1).max(120).optional(),quoteEvidenceClaimId:J.optional(),maxSlippageBps:I().int().min(0).max(1e4).optional(),minOutRaw:Hy.optional(),policySource:W([`user_explicit`,`adapter_policy_from_quote_evidence`]).optional(),policyEvidenceClaimId:J.optional()}).strict().superRefine((e,t)=>{e.status===`required_and_verified`&&(e.quoteEvidenceId===void 0||e.quoteEvidenceClaimId===void 0||e.maxSlippageBps===void 0||e.minOutRaw===void 0||e.policySource===void 0||e.policyEvidenceClaimId===void 0)&&t.addIssue({code:`custom`,message:`Verified min-out evidence requires quoteEvidenceId, quoteEvidenceClaimId, maxSlippageBps, minOutRaw, policySource, and policyEvidenceClaimId`}),e.quoteEvidenceId!==void 0&&e.quoteEvidenceClaimId===void 0&&t.addIssue({code:`custom`,path:[`quoteEvidenceClaimId`],message:`quoteEvidenceId requires quoteEvidenceClaimId`}),e.quoteEvidenceId===void 0&&e.quoteEvidenceClaimId!==void 0&&t.addIssue({code:`custom`,path:[`quoteEvidenceClaimId`],message:`quoteEvidenceClaimId requires quoteEvidenceId`}),e.minOutRaw!==void 0&&e.quoteEvidenceClaimId===void 0&&t.addIssue({code:`custom`,path:[`quoteEvidenceClaimId`],message:`minOutRaw requires quoteEvidenceClaimId`}),e.maxSlippageBps!==void 0&&e.policySource===void 0&&t.addIssue({code:`custom`,path:[`policySource`],message:`maxSlippageBps requires policySource`}),e.policySource!==void 0&&e.policyEvidenceClaimId===void 0&&t.addIssue({code:`custom`,path:[`policyEvidenceClaimId`],message:`policySource requires policyEvidenceClaimId`}),e.policySource===void 0&&e.policyEvidenceClaimId!==void 0&&t.addIssue({code:`custom`,path:[`policyEvidenceClaimId`],message:`policyEvidenceClaimId requires policySource`})}),ub=B({checkedAt:Vy,ownerAccount:d_,objects:z(B({objectId:Uy,role:W([`input_coin`,`gas_coin`,`protocol_object`,`shared_object`,`receiving_object`]),ownership:W([`owned_by_account`,`shared_object`,`immutable_or_package`,`not_owned_by_account`]),evidenceClaimId:J}).strict()).min(1)}).strict(),db=B({evidenceClaimId:J,transactionDigest:f_,provider:ly,checksEnabled:G(!0),simulatedAt:Vy,status:W([`success`,`failed`,`unavailable`]),requiredFields:z(W(fy)).min(fy.length),missingFields:z(W(fy)).default([]),failureReason:F().min(1).max(240).optional()}).strict().refine(e=>e.status!==`success`||e.missingFields.length===0,{message:`Successful simulation evidence must not have missing required fields`}).refine(e=>fy.every(t=>e.requiredFields.includes(t)),{message:`Simulation evidence must include every required simulation field`}).refine(e=>e.status===`success`||e.failureReason!==void 0,{message:`Failed or unavailable simulation evidence requires failureReason`}).refine(e=>e.status!==`success`||e.failureReason===void 0,{message:`Successful simulation evidence must not include failureReason`}),fb=B({fields:z(W(dy)).min(dy.length),transactionDigest:f_,source:G(`review_model_or_adapter_equivalent`),purpose:G(`human_review_before_wallet_authorization`)}).strict().refine(e=>dy.every(t=>e.fields.includes(t)),{message:`Human-readable review fields must include every required review field`}),pb=B({runtimeStatus:G(`emitted_pre_handoff`),mcpAndReviewUiMayExpose:z(W([`human_readable_review`,`ptb_visualization_artifact`,`diagnostics`,`status_checks`])).min(1),prohibited:z(W(py)).min(1)}).strict().superRefine((e,t)=>{Zy(t,e.prohibited,py,[`prohibited`],`prohibited`)}),mb=B({schemaVersion:G(1),adapterId:F().min(1).max(120),protocol:F().min(1).max(120),actionKind:F().min(1).max(120),network:G(`sui:mainnet`),inputProvenance:nb,sourceReferences:z(rb).min(1),evidenceClaims:z(ib).min(1),rawQuantities:z(ab).min(1),gas:sb,expiry:cb,slippageOrMinOut:lb,objectOwnership:ub,simulation:db,humanReadableReview:fb,outputBoundary:pb,reviewedTransactionDigest:f_}).strict().superRefine((e,t)=>{let n=new Set,r=new Map,i=new Map;e.sourceReferences.forEach((e,a)=>{n.has(e.id)&&t.addIssue({code:`custom`,path:[`sourceReferences`,a,`id`],message:`sourceReferences id must be unique: ${e.id}`}),n.add(e.id),r.has(e.id)||(r.set(e.id,e),i.set(e.id,a))});let a=new Set,o=new Map,s=new Map;e.evidenceClaims.forEach((e,n)=>{a.has(e.id)&&t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`id`],message:`evidenceClaims id must be unique: ${e.id}`}),a.add(e.id),o.has(e.id)||(o.set(e.id,e),s.set(e.id,n))});let c=(e,n)=>{if(e===void 0)return;let i=r.get(e);if(i!==void 0)return i;t.addIssue({code:`custom`,path:n,message:`source evidence id must reference sourceReferences[].id: ${e}`})},l=(e,n,r,a)=>{if(e===void 0)return;let o=c(e,r);if(o===void 0)return;let s=i.get(e),l=s===void 0?r:[`sourceReferences`,s];n.kinds.includes(o.kind)||t.addIssue({code:`custom`,path:[...l,`kind`],message:`${a} source kind must be one of ${n.kinds.join(`, `)}`}),Xy(t,o.fields,n.fields,[...l,`fields`],`${a} sourceReferences fields`)},u=(e,n,r,i)=>{if(e===void 0){t.addIssue({code:`custom`,path:r,message:`${i} must reference evidenceClaims[].id`});return}let a=o.get(e);if(a===void 0)t.addIssue({code:`custom`,path:r,message:`${i} must reference evidenceClaims[].id: ${e}`});else{if(a.factKind!==n){let a=s.get(e),o=a===void 0?r:[`evidenceClaims`,a,`factKind`];t.addIssue({code:`custom`,path:o,message:`${i} evidence claim factKind must be ${n}`})}return a}};if(e.evidenceClaims.forEach((e,n)=>{e.factKind===`raw_quantity_amount`&&l(e.sourceEvidenceId,zy.raw_quantity_amount.byRole[e.role],[`evidenceClaims`,n,`sourceEvidenceId`],`evidenceClaims[${n}].raw_quantity_amount`),e.factKind===`unit_metadata`&&l(e.sourceEvidenceId,zy.unit_metadata.bySource[e.source],[`evidenceClaims`,n,`sourceEvidenceId`],`evidenceClaims[${n}].unit_metadata`),e.factKind===`gas_unresolved_status`&&l(e.sourceEvidenceId,zy.gas_unresolved_status,[`evidenceClaims`,n,`sourceEvidenceId`],`evidenceClaims[${n}].gas_unresolved_status`),e.factKind===`expiry_status`&&(l(e.sourceEvidenceId,zy.expiry_status[e.status],[`evidenceClaims`,n,`sourceEvidenceId`],`evidenceClaims[${n}].expiry_status`),(e.status===`current`||e.status===`expired`)&&e.expiresAt===void 0&&t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`expiresAt`],message:`Current or expired expiry claim requires expiresAt`}),(e.status===`not_provided`||e.status===`not_applicable`)&&e.reason===void 0&&t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`reason`],message:`Unavailable expiry claim requires reason`}),(e.status===`not_provided`||e.status===`not_applicable`)&&e.expiresAt!==void 0&&t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`expiresAt`],message:`Unavailable expiry claim must not include expiresAt`}),e.status===`current`&&e.expiresAt!==void 0&&Date.parse(e.expiresAt)<=Date.parse(e.checkedAt)&&t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`expiresAt`],message:`Current expiry claim requires expiresAt after checkedAt`}),e.status===`expired`&&e.expiresAt!==void 0&&Date.parse(e.expiresAt)>Date.parse(e.checkedAt)&&t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`expiresAt`],message:`Expired expiry claim requires expiresAt at or before checkedAt`})),e.factKind===`quote_min_out`&&l(e.sourceEvidenceId,zy.quote_min_out,[`evidenceClaims`,n,`sourceEvidenceId`],`evidenceClaims[${n}].quote_min_out`),e.factKind===`slippage_policy`&&(l(e.sourceEvidenceId,zy.slippage_policy.bySource[e.policySource],[`evidenceClaims`,n,`sourceEvidenceId`],`evidenceClaims[${n}].slippage_policy`),e.policySource===`adapter_policy_from_quote_evidence`&&e.minOutRaw===void 0&&t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`minOutRaw`],message:`Adapter-derived slippage policy claim requires minOutRaw`})),e.factKind===`object_ownership`&&l(e.sourceEvidenceId,zy.object_ownership,[`evidenceClaims`,n,`sourceEvidenceId`],`evidenceClaims[${n}].object_ownership`),e.factKind===`simulation_result`&&(l(e.sourceEvidenceId,zy.simulation_result,[`evidenceClaims`,n,`sourceEvidenceId`],`evidenceClaims[${n}].simulation_result`),e.status===`success`&&e.missingFields.length!==0&&t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`missingFields`],message:`Successful simulation claim must not have missing required fields`}),fy.every(t=>e.requiredFields.includes(t))||t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`requiredFields`],message:`Simulation claim must include every required simulation field`}),e.status!==`success`&&e.failureReason===void 0&&t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`failureReason`],message:`Failed or unavailable simulation claim requires failureReason`}),e.status===`success`&&e.failureReason!==void 0&&t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`failureReason`],message:`Successful simulation claim must not include failureReason`}))}),e.rawQuantities.forEach((e,n)=>{let r=u(e.amountClaimId,`raw_quantity_amount`,[`rawQuantities`,n,`amountClaimId`],`rawQuantities[${n}].amountClaimId`);r?.factKind===`raw_quantity_amount`&&(Y(t,e.role,r.role,[`rawQuantities`,n,`role`],`rawQuantities[${n}].role`),Y(t,e.rawAmount,r.rawAmount,[`rawQuantities`,n,`rawAmount`],`rawQuantities[${n}].rawAmount`),eb(t,e.asset,r.asset,[`rawQuantities`,n,`asset`],`rawQuantities[${n}].asset`));let i=u(e.unit.unitClaimId,`unit_metadata`,[`rawQuantities`,n,`unit`,`unitClaimId`],`rawQuantities[${n}].unit.unitClaimId`);i?.factKind===`unit_metadata`&&(Y(t,e.unit.source,i.source,[`rawQuantities`,n,`unit`,`source`],`rawQuantities[${n}].unit.source`),Y(t,e.unit.decimals,i.decimals,[`rawQuantities`,n,`unit`,`decimals`],`rawQuantities[${n}].unit.decimals`),e.asset.coinType!==void 0&&Y(t,e.asset.coinType,i.coinType,[`rawQuantities`,n,`asset`,`coinType`],`rawQuantities[${n}].asset.coinType`))}),e.gas.gasBudgetRaw!==void 0){let n=u(e.gas.gasBudgetClaimId,`raw_quantity_amount`,[`gas`,`gasBudgetClaimId`],`gas.gasBudgetClaimId`);n?.factKind===`raw_quantity_amount`&&(Y(t,n.role,By.gasBudgetClaimId.role,[`gas`,`gasBudgetClaimId`],`gas.gasBudgetClaimId role`),tb(t,n.asset,By.gasBudgetClaimId.assetCoinType,[`gas`,`gasBudgetClaimId`],`gas.gasBudgetClaimId asset`),Y(t,e.gas.gasBudgetRaw,n.rawAmount,[`gas`,`gasBudgetRaw`],`gas.gasBudgetRaw`))}if(e.gas.gasUsedRaw!==void 0){let n=u(e.gas.gasUsedClaimId,`raw_quantity_amount`,[`gas`,`gasUsedClaimId`],`gas.gasUsedClaimId`);n?.factKind===`raw_quantity_amount`&&(Y(t,n.role,By.gasUsedClaimId.role,[`gas`,`gasUsedClaimId`],`gas.gasUsedClaimId role`),tb(t,n.asset,By.gasUsedClaimId.assetCoinType,[`gas`,`gasUsedClaimId`],`gas.gasUsedClaimId asset`),Y(t,e.gas.gasUsedRaw,n.rawAmount,[`gas`,`gasUsedRaw`],`gas.gasUsedRaw`))}if(e.gas.unresolvedReason!==void 0){let n=u(e.gas.unresolvedClaimId,`gas_unresolved_status`,[`gas`,`unresolvedClaimId`],`gas.unresolvedClaimId`);n?.factKind===`gas_unresolved_status`&&(Y(t,n.status,`unresolved`,[`gas`,`unresolvedClaimId`],`gas.unresolvedClaimId status`),Y(t,e.gas.checkedAt,n.checkedAt,[`gas`,`checkedAt`],`gas.checkedAt`),Y(t,e.gas.unresolvedReason,n.reason,[`gas`,`unresolvedReason`],`gas.unresolvedReason`))}e.gas.gasObjects?.forEach((e,n)=>{let r=u(e.ownershipClaimId,`object_ownership`,[`gas`,`gasObjects`,n,`ownershipClaimId`],`gas.gasObjects[${n}].ownershipClaimId`);r?.factKind===`object_ownership`&&(Y(t,e.objectId,r.objectId,[`gas`,`gasObjects`,n,`objectId`],`gas.gasObjects[${n}].objectId`),Y(t,e.ownerAccount,r.ownerAccount,[`gas`,`gasObjects`,n,`ownerAccount`],`gas.gasObjects[${n}].ownerAccount`),Y(t,r.ownership,By.gasObjectOwnershipClaimId.ownership,[`gas`,`gasObjects`,n,`ownershipClaimId`],`gas.gasObjects[${n}].ownershipClaimId ownership`))});let d=u(e.expiry.evidenceClaimId,`expiry_status`,[`expiry`,`evidenceClaimId`],`expiry.evidenceClaimId`);if(d?.factKind===`expiry_status`&&(Y(t,e.expiry.status,d.status,[`expiry`,`status`],`expiry.status`),Y(t,e.expiry.checkedAt,d.checkedAt,[`expiry`,`checkedAt`],`expiry.checkedAt`),e.expiry.status===`current`||e.expiry.status===`expired`?Y(t,e.expiry.expiresAt,d.expiresAt,[`expiry`,`expiresAt`],`expiry.expiresAt`):Y(t,e.expiry.reason,d.reason,[`expiry`,`reason`],`expiry.reason`)),e.slippageOrMinOut.quoteEvidenceClaimId!==void 0){let n=u(e.slippageOrMinOut.quoteEvidenceClaimId,`quote_min_out`,[`slippageOrMinOut`,`quoteEvidenceClaimId`],`slippageOrMinOut.quoteEvidenceClaimId`);n?.factKind===`quote_min_out`&&(Y(t,e.slippageOrMinOut.quoteEvidenceId,n.quoteEvidenceId,[`slippageOrMinOut`,`quoteEvidenceId`],`slippageOrMinOut.quoteEvidenceId`),Y(t,e.slippageOrMinOut.minOutRaw,n.minOutRaw,[`slippageOrMinOut`,`minOutRaw`],`slippageOrMinOut.minOutRaw`))}if(e.slippageOrMinOut.minOutRaw!==void 0&&(e.rawQuantities.some(t=>t.role===`minimum_output`&&t.rawAmount===e.slippageOrMinOut.minOutRaw)||t.addIssue({code:`custom`,path:[`slippageOrMinOut`,`minOutRaw`],message:`slippageOrMinOut.minOutRaw must match a minimum_output rawQuantities entry`})),e.slippageOrMinOut.policyEvidenceClaimId!==void 0){let n=u(e.slippageOrMinOut.policyEvidenceClaimId,`slippage_policy`,[`slippageOrMinOut`,`policyEvidenceClaimId`],`slippageOrMinOut.policyEvidenceClaimId`);n?.factKind===`slippage_policy`&&(Y(t,e.slippageOrMinOut.policySource,n.policySource,[`slippageOrMinOut`,`policySource`],`slippageOrMinOut.policySource`),Y(t,e.slippageOrMinOut.maxSlippageBps,n.maxSlippageBps,[`slippageOrMinOut`,`maxSlippageBps`],`slippageOrMinOut.maxSlippageBps`),n.policySource===`adapter_policy_from_quote_evidence`&&Y(t,e.slippageOrMinOut.minOutRaw,n.minOutRaw,[`slippageOrMinOut`,`minOutRaw`],`slippageOrMinOut.minOutRaw`))}e.objectOwnership.objects.forEach((n,r)=>{let i=u(n.evidenceClaimId,`object_ownership`,[`objectOwnership`,`objects`,r,`evidenceClaimId`],`objectOwnership.objects[${r}].evidenceClaimId`);i?.factKind===`object_ownership`&&(Y(t,n.objectId,i.objectId,[`objectOwnership`,`objects`,r,`objectId`],`objectOwnership.objects[${r}].objectId`),Y(t,e.objectOwnership.ownerAccount,i.ownerAccount,[`objectOwnership`,`ownerAccount`],`objectOwnership.ownerAccount`),Y(t,n.ownership,i.ownership,[`objectOwnership`,`objects`,r,`ownership`],`objectOwnership.objects[${r}].ownership`))});let f=u(e.simulation.evidenceClaimId,`simulation_result`,[`simulation`,`evidenceClaimId`],`simulation.evidenceClaimId`);f?.factKind===`simulation_result`&&(Y(t,e.simulation.provider,f.provider,[`simulation`,`provider`],`simulation.provider`),Y(t,e.simulation.checksEnabled,f.checksEnabled,[`simulation`,`checksEnabled`],`simulation.checksEnabled`),Y(t,e.simulation.simulatedAt,f.simulatedAt,[`simulation`,`simulatedAt`],`simulation.simulatedAt`),Y(t,e.simulation.status,f.status,[`simulation`,`status`],`simulation.status`),$y(t,e.simulation.requiredFields,f.requiredFields,[`simulation`,`requiredFields`],`simulation.requiredFields`),$y(t,e.simulation.missingFields,f.missingFields,[`simulation`,`missingFields`],`simulation.missingFields`),Y(t,e.simulation.failureReason,f.failureReason,[`simulation`,`failureReason`],`simulation.failureReason`))}).superRefine((e,t)=>{let n=e.reviewedTransactionDigest;Y(t,e.humanReadableReview.transactionDigest,n,[`humanReadableReview`,`transactionDigest`],`humanReadableReview.transactionDigest`),Y(t,e.simulation.transactionDigest,n,[`simulation`,`transactionDigest`],`simulation.transactionDigest`)}),hb=B({contractVersion:G(uy),artifactKind:G(`ptb_visualization`),generatedAt:Vy,source:B({adapterId:F().min(1).max(120),planId:F().min(1).max(120).optional(),sourceKind:W([`review_time_generated_transaction_kind`,`review_time_ir`,`renderer_model`]),authority:G(`visualization_only_not_wallet_authorization`),renderer:B({name:F().min(1).max(120),packageName:F().min(1).max(120).optional(),version:F().min(1).max(80).optional()}).strict().optional()}).strict(),mermaid:B({diagramType:G(`flowchart`),text:Jy(2e4,`mermaid.text`),namedText:Jy(2e4,`mermaid.namedText`)}).strict(),diagnostics:z(B({severity:W([`info`,`warning`,`error`]),code:F().min(1).max(120),message:Jy(512,`diagnostics.message`),source:W([`adapter`,`renderer`,`schema`,`simulation`])}).strict()).default([]),unsupportedUse:z(W(my)).min(1),executableMaterial:B({included:G(!1),policy:G(`mcp_and_review_ui_outputs_must_not_include_executable_transaction_material`)}).strict()}).strict().superRefine((e,t)=>{Zy(t,e.unsupportedUse,my,[`unsupportedUse`],`unsupportedUse`)}),gb=U(F(),R()),_b=W(ay),vb=W(oy);W([`ready_for_wallet_review`,`refresh_required`,`blocked`]);var yb=W(sy);W([`proposed`,`awaiting_wallet`,`wallet_connected`,`ready_for_wallet_review`,`refresh_required`,`blocked`,`expired`,`awaiting_signature`,`submitting`,`awaiting_chain_result`,`stopped`,`request_failed`,`outcome_unknown`,`completed`]);var bb=B({id:F(),label:F(),status:W([`pass`,`warning`,`fail`]),message:F(),source:W([`registry`,`quote`,`wallet`,`simulation`,`adapter`,`network`,`proposal`])}),xb=F().min(1),Sb=`human_readable_review`,Cb=`review_time_simulation`,wb=B({stageCatalogId:F().min(1),adapterId:F(),protocol:F(),actionKind:F(),completedStages:z(xb),missingStages:z(xb)}).strict().superRefine((e,t)=>{let n=Tb(e.completedStages);n&&t.addIssue({code:`custom`,path:[`completedStages`],message:`completedStages contains duplicate stage '${n}'`});let r=Tb(e.missingStages);r&&t.addIssue({code:`custom`,path:[`missingStages`],message:`missingStages contains duplicate stage '${r}'`});for(let n of e.completedStages)e.missingStages.includes(n)&&t.addIssue({code:`custom`,path:[`missingStages`],message:`stage '${n}' cannot be both completed and missing`})});function Tb(e){let t=new Set;for(let n of e){if(t.has(n))return n;t.add(n)}}var Eb=B({symbol:F(),amount:F(),coinType:F().optional(),approx:L().optional()}).strict(),Db=Eb.extend({amountKind:G(`display_intent`).default(`display_intent`)}),Ob=B({outgoing:z(Db),expectedIncoming:z(Db),minimumIncoming:z(Db).optional(),fees:z(Db).optional()}),kb=B({outgoing:z(Eb),expectedIncoming:z(Eb),minimumIncoming:z(Eb).optional(),fees:z(Eb).optional()}),Ab=B({before:z(Eb),after:z(Eb),delta:z(Eb)}),jb=B({computationCostRaw:__(`computationCostRaw`),storageCostRaw:__(`storageCostRaw`),storageRebateRaw:__(`storageRebateRaw`),nonRefundableStorageFeeRaw:__(`nonRefundableStorageFeeRaw`)}).strict(),Mb=B({address:d_,coinType:F().min(1).max(512).refine(e=>{try{return S_(e)===e}catch{return!1}},`Expected a normalized Sui struct tag coin type`),amount:x_(`balanceChanges[].amount`)}).strict(),Nb=B({objectId:d_,objectType:F().min(1).max(512).optional(),inputState:F().min(1).max(80),outputState:F().min(1).max(80),idOperation:F().min(1).max(80)}).strict(),Pb=B({provider:ly,checksEnabled:L(),success:L(),gasCostSummary:jb.optional(),balanceChanges:z(Mb).optional(),objectChanges:z(Nb).optional(),error:F().optional()}),Fb=Pb,Ib=Pb.extend({checksEnabled:G(!0),success:G(!0),gasCostSummary:jb,balanceChanges:z(Mb),objectChanges:z(Nb),error:uc().optional()}).strict(),Lb=B({role:W([`input`,`expected_output`,`minimum_output`,`fee`]),symbol:F(),coinType:F().min(1).max(512).refine(e=>{try{return S_(e),!0}catch{return!1}},`Expected a Sui struct tag coin type`),decimals:I().int().min(0).max(255),rawAmount:__(`rawAmount`),rawAmountSource:G(`quote_policy_evidence`),displayAmount:F().optional(),displayAmountSource:G(`user_display_intent_not_signing_input`).optional()}).strict().superRefine((e,t)=>{e.displayAmount!==void 0&&e.displayAmountSource===void 0&&t.addIssue({code:`custom`,path:[`displayAmountSource`],message:`displayAmountSource is required when displayAmount is present`}),e.displayAmount===void 0&&e.displayAmountSource!==void 0&&t.addIssue({code:`custom`,path:[`displayAmount`],message:`displayAmount is required when displayAmountSource is present`})}),Rb=B({role:W([`connected_account`,`output_recipient`]),address:d_}).strict(),zb=B({kind:G(`swap_output_asset`),symbol:F(),coinType:F().min(1).max(512).refine(e=>{try{return S_(e),!0}catch{return!1}},`Expected a Sui struct tag coin type`),protocol:F(),poolKey:F(),direction:W([`base_to_quote`,`quote_to_base`])}).strict(),Bb=B({id:F(),label:F(),source:H([W([`registry`,`quote`,`wallet`,`simulation`,`adapter`,`network`,`proposal`]),W([`transaction_material`,`digest_commitment`])]),summary:F()}).strict(),Vb=B({id:F(),label:F(),reason:F()}).strict(),Hb=B({proposedAction:B({title:F(),summary:F(),actionKind:F(),adapterId:F(),protocol:F(),network:G(`sui:mainnet`)}).strict(),recipients:z(Rb),evidenceUsed:z(Bb),missingEvidence:z(Vb),requiredUserChoices:z(Vb),unsupportedClaims:z(Vb),freshness:B({status:G(`current`),evaluatedAt:F(),expiresAt:F(),reason:F()}).strict(),blockingChecks:z(bb)}).strict(),Ub=B({assetFlow:B({outgoing:z(Lb),expectedIncoming:z(Lb),minimumIncoming:z(Lb),fees:z(Lb)}).strict(),targets:z(zb)}).strict(),Wb=hc(`kind`,[Hb.extend({kind:G(`swap_human_readable_review`)}).merge(Ub)]),Gb=B({id:F(),actionKind:F(),adapterId:F(),protocol:F(),title:F(),summary:F(),assetFlowPreview:Ob,reviewModel:iy.optional(),adapterData:gb,createdAt:F(),expiresAt:F().optional(),registryVersion:F().optional(),preliminaryChecks:z(bb).optional()}),Kb=B({planId:F(),reviewSessionId:F(),account:d_,checks:z(bb),assetFlowActual:kb.optional(),beforeAfterBalance:Ab.optional(),simulation:Fb.optional(),humanReadableReview:Wb.optional(),transactionReviewData:mb.optional(),ptbVisualization:hb.optional(),adapterLifecycle:wb.optional(),updatedAt:F()}),qb=hc(`status`,[Kb.extend({status:G(`ready_for_wallet_review`),evidenceValidity:uc().optional(),blockedReason:uc().optional(),refreshReason:uc().optional()}),Kb.extend({status:G(`refresh_required`),evidenceValidity:G(`invalidated`).optional(),refreshReason:vb,blockedReason:uc().optional()}),Kb.extend({status:G(`blocked`),evidenceValidity:G(`invalidated`).optional(),blockedReason:_b,refreshReason:uc().optional()})]).superRefine((e,t)=>{if(e.evidenceValidity===`invalidated`)for(let n of cy)e[n]!==void 0&&t.addIssue({code:`custom`,path:[n],message:`Invalidated review evidence cannot carry current material-derived facts`});let n=e.adapterLifecycle;if(n!==void 0&&Jb(e,t),e.humanReadableReview!==void 0&&n===void 0&&t.addIssue({code:`custom`,path:[`humanReadableReview`],message:`humanReadableReview requires adapterLifecycle evidence stage provenance`}),e.simulation!==void 0&&n===void 0&&t.addIssue({code:`custom`,path:[`simulation`],message:`simulation requires adapterLifecycle evidence stage provenance`}),e.ptbVisualization!==void 0){let e=n?.completedStages??[];e.includes(`transaction_material_build_or_verify`)&&e.includes(`digest_commitment`)||t.addIssue({code:`custom`,path:[`ptbVisualization`],message:`ptbVisualization requires completed transaction material and digest commitment lifecycle stages`})}let r=e.status===`ready_for_wallet_review`;e.transactionReviewData!==void 0&&!r&&t.addIssue({code:`custom`,path:[`transactionReviewData`],message:`transactionReviewData is only valid on ready_for_wallet_review`}),e.status===`ready_for_wallet_review`&&n!==void 0&&(e.transactionReviewData===void 0&&t.addIssue({code:`custom`,path:[`transactionReviewData`],message:`ready_for_wallet_review requires an emitted wallet review contract`}),(n===void 0||n.missingStages.length!==0)&&t.addIssue({code:`custom`,path:[`adapterLifecycle`],message:`ready_for_wallet_review requires a completed adapterLifecycle with no missing stages`}),e.humanReadableReview===void 0&&t.addIssue({code:`custom`,path:[`humanReadableReview`],message:`ready_for_wallet_review requires humanReadableReview public evidence`}),e.simulation===void 0&&t.addIssue({code:`custom`,path:[`simulation`],message:`ready_for_wallet_review requires successful simulation public evidence`})),e.status===`blocked`&&(e.blockedReason===`producer_stage_missing`&&n===void 0&&t.addIssue({code:`custom`,path:[`adapterLifecycle`],message:`producer_stage_missing requires adapterLifecycle with at least one missing stage`}),e.blockedReason===`producer_stage_missing`&&n!==void 0&&n.missingStages.length===0&&t.addIssue({code:`custom`,path:[`blockedReason`],message:`producer_stage_missing requires at least one adapterLifecycle.missingStages entry`}),e.blockedReason===`wallet_review_contract_emit_missing`&&e.transactionReviewData!==void 0&&t.addIssue({code:`custom`,path:[`transactionReviewData`],message:`wallet_review_contract_emit_missing requires the wallet review contract to be absent`}),e.blockedReason===`wallet_review_contract_emit_missing`&&n===void 0&&t.addIssue({code:`custom`,path:[`adapterLifecycle`],message:`wallet_review_contract_emit_missing requires adapterLifecycle`}),e.blockedReason===`wallet_review_contract_emit_missing`&&n!==void 0&&n.missingStages.length!==0&&t.addIssue({code:`custom`,path:[`blockedReason`],message:`wallet_review_contract_emit_missing requires a completed adapterLifecycle with no missing stages`}),e.blockedReason===`wallet_review_contract_emit_missing`&&e.evidenceValidity!==`invalidated`&&e.humanReadableReview===void 0&&t.addIssue({code:`custom`,path:[`humanReadableReview`],message:`wallet_review_contract_emit_missing requires humanReadableReview public evidence`}),e.blockedReason===`wallet_review_contract_emit_missing`&&e.evidenceValidity!==`invalidated`&&e.simulation===void 0&&t.addIssue({code:`custom`,path:[`simulation`],message:`wallet_review_contract_emit_missing requires simulation public evidence`}))});function Jb(e,t){let n=e.adapterLifecycle;n&&(e.humanReadableReview!==void 0&&Yb(t,n,Sb,[`humanReadableReview`]),e.simulation!==void 0&&(Yb(t,n,Cb,[`simulation`]),Yb(t,n,Sb,[`simulation`]),Xb(t,e.simulation,[`simulation`])),n.missingStages.includes(Cb)&&e.simulation!==void 0&&t.addIssue({code:`custom`,path:[`simulation`],message:`simulation public evidence cannot be present while review_time_simulation is missing`}),n.missingStages.includes(Sb)&&e.humanReadableReview!==void 0&&t.addIssue({code:`custom`,path:[`humanReadableReview`],message:`humanReadableReview public evidence cannot be present while human_readable_review is missing`}))}function Yb(e,t,n,r){t.completedStages.includes(n)||e.addIssue({code:`custom`,path:r,message:`${r.join(`.`)} requires completed adapterLifecycle stage '${n}'`}),t.missingStages.includes(n)&&e.addIssue({code:`custom`,path:r,message:`${r.join(`.`)} cannot be present while adapterLifecycle stage '${n}' is missing`})}function Xb(e,t,n){Ib.safeParse(t).success||e.addIssue({code:`custom`,path:n,message:`simulation public evidence requires a successful checks-enabled review-time simulation projection`})}var Zb=B({topic:F().min(1),accounts:z(d_).min(1),methods:z(F()),chain:G(P_),expiresAt:F().datetime(),walletName:F().optional()}).strict(),Qb=hc(`status`,[B({topic:F().min(1),version:I().int().positive(),status:G(`present`),session:Zb}).strict(),B({topic:F().min(1),version:I().int().positive(),status:W([`absent`,`unusable`])}).strict()]),$b=B({runId:F_,sequence:I().int().positive(),observedAt:F().datetime()}).strict();$b.extend({sessions:z(Qb)}).strict();var ex=B({kind:G(`wallet_service_recovery`),priorRunId:F_,admittedAt:F().datetime(),updatedAt:F().datetime()}),tx=H([ex.extend({phase:G(`stopping`)}).strict(),ex.extend({phase:G(`starting`),nextRunId:F_}).strict(),ex.extend({outcome:W([`available`,`failed`,`superseded`,`server_restarted`]),nextRunId:F_.optional(),message:F().optional()}).strict()]),nx=`A wallet connection provides account context; it is not a transaction approval or proof of address ownership.`,rx=`Review evidence is not a safety guarantee. Only an explicit card action and wallet approval may authorize this exact transaction.`,ix=V_.extend({pendingAction:G(`disconnect`).optional()});W([`input_required`,`awaiting_approval`,`disconnect_pending`]);var ax=B({action:G(`connect`),walletRunId:F_}).strict(),ox=B({action:G(`disconnect`),walletRunId:F_,connectionId:F().min(1)}).strict(),sx=B({action:G(`use_account`),walletRunId:F_,connectionId:F().min(1),account:d_}).strict(),cx=B({action:W([`prepare_review`,`request_signature`]),connectionId:F().min(1),walletRunId:F_,account:d_,reviewRevision:I().int().nonnegative()}).strict(),lx=H([ax,ox,sx,cx,B({action:W([`cancel`,`stop_connection`,`stop_waiting`,`read_result`])}).strict()]),ux=H([ax,cx.extend({action:G(`prepare_review`)})]),dx=B({kind:W([`connect`,`review`]),mode:W([`connect`,`review`,`review_manage`]),allowedActions:z(W(W_)),actionRemainingMs:I().int().nonnegative(),nextStateReadAfterMs:I().int().nonnegative().optional(),automaticAction:ux.optional(),observe:L(),walletAvailability:R_,walletObservation:$b.optional(),runtimeRecovery:tx.optional(),connectionConflict:H_.optional(),manageableConnectionIds:z(F().min(1)),connectionReconciliationRequired:G(!0).optional(),usableConnectionId:F().min(1).optional(),assetReadAccount:U_.optional(),acceptedWalletRunId:F_.optional(),progress:z_,boundary:W([nx,rx]),connections:z(ix),activeAccount:F().optional(),connection:ix.optional(),connectionAction:W([`connect`,`disconnect`]).optional(),review:B({reviewSessionId:F(),plan:Gb,reviewRevision:I().int().nonnegative(),status:yb,account:F().optional(),preparing:L(),accountRequestPending:G(!0).optional(),error:F().optional(),state:qb.optional()}).strict().optional(),request:N_.optional(),receipt:R().optional(),netGasMist:F().regex(/^-?[0-9]+$/).optional(),observationStopped:L().optional()}).strict().superRefine((e,t)=>{let n=e.connections.find(t=>t.connectionId===e.usableConnectionId);e.usableConnectionId&&(!n||n.status!==`connected`||e.walletAvailability.status!==`available`||e.connectionConflict||e.connectionReconciliationRequired||e.connections.some(e=>e.pendingAction||e.status===`awaiting_approval`))&&t.addIssue({code:`custom`,path:[`usableConnectionId`],message:`The usable connection must match current connection facts.`}),(new Set(e.manageableConnectionIds).size!==e.manageableConnectionIds.length||e.manageableConnectionIds.some(t=>!e.connections.some(e=>e.connectionId===t&&!e.pendingAction&&e.status!==`awaiting_approval`)))&&t.addIssue({code:`custom`,path:[`manageableConnectionIds`],message:`Management must name distinct recorded targets without pending operations.`}),e.connectionReconciliationRequired&&(e.usableConnectionId||e.assetReadAccount?.status===`available`||e.allowedActions.some(e=>[`connect`,`use_account`,`prepare_review`,`request_signature`].includes(e)))&&t.addIssue({code:`custom`,path:[`connectionReconciliationRequired`],message:`Unrecorded SDK connections cannot authorize connection or account use.`}),e.assetReadAccount?.status===`available`&&(!n||!n.accounts.includes(e.assetReadAccount.account)||e.activeAccount!==e.assetReadAccount.account)&&t.addIssue({code:`custom`,path:[`assetReadAccount`],message:`The default address must belong to the usable connection and stored selection.`})});function fx(e,t,n=!1){return e.connections.filter(r=>r.connectionId===e.usableConnectionId&&r.accounts.includes(t)&&(!n||r.methods.includes(`sui_signTransaction`)))}var px=`sui-mcp.local-data`,mx=16777216,X=F().uuid(),hx=I().int().nonnegative().safe(),gx=F().regex(/^[a-f0-9]{64}$/),_x=hc(`status`,[B({status:G(`no_file`)}).strict(),B({status:G(`receiving`)}).strict(),B({status:G(`checking`)}).strict(),B({status:G(`check_required`),message:F().min(1)}).strict(),B({status:G(`can_restore`)}).strict(),B({status:G(`cannot_restore`),reason:W([`invalid_backup`,`file_unavailable`,`wallet_request_unsettled`,`operation_busy`,`input_unavailable`,`check_failed`]),message:F().min(1)}).strict()]);B({fileId:X,sha256:gx,totalSize:hx,dataEpoch:hx,userDataRevision:hx,check:_x}).strict();var vx=hc(`kind`,[B({kind:G(`set_endpoint`),endpoint:W([`grpc`,`graphql`]),value:F().min(1)}).strict(),B({kind:G(`restore_endpoint`),endpoint:W([`grpc`,`graphql`])}).strict(),B({kind:W([`clear_read_address`,`export_local_data`,`download_backup`,`import_local_data`,`reset_local_data`,`restart_wallet_service`])}).strict()]),yx=W([`acknowledged`,`not_completed`,`unconfirmed`,`unsupported`]),bx=B({method:G(`ui/download-file`),code:G(-32601)}).strict(),xx=W([`acknowledged`,`cancelled`,`expired`,`server_restarted`,`data_replaced`,`source_unavailable`,`stored_locally`,`local_save_failed`]),Sx=B({device:F().regex(/^\d+$/),inode:F().regex(/^\d+$/)}).strict(),Cx=W([`not_published`,`target_conflict`,`source_unavailable`,`interrupted`]),wx=B({status:W([`needs_consent`,`saving`,`saved`,`failed`]),attemptId:X,fileId:X,sha256:gx,totalSize:hx,destination:F(),ownerId:F().min(1),currentSaveAttemptId:X.optional(),attempts:z(B({saveAttemptId:X,previousSaveAttemptId:X.optional(),admittedAt:F().datetime(),allowPossibleCopy:L()}).strict()),sourceIdentity:Sx.optional(),savedAt:F().datetime().optional(),failure:Cx.optional()}).strict().superRefine((e,t)=>{(e.status===`needs_consent`?e.attempts.length!==0||e.currentSaveAttemptId!==void 0:!e.currentSaveAttemptId||!e.attempts.some(t=>t.saveAttemptId===e.currentSaveAttemptId))&&t.addIssue({code:`custom`,message:`A local save must identify its admitted attempt.`}),(new Set(e.attempts.map(e=>e.saveAttemptId)).size!==e.attempts.length||e.status===`saved`!=(e.savedAt!==void 0)||e.status===`saved`&&!e.sourceIdentity||e.status===`failed`!=(e.failure!==void 0))&&t.addIssue({code:`custom`,message:`Local save evidence must match its state.`})});B({currentAttemptId:X,attempts:z(B({attemptId:X,admittedAt:F().datetime(),previousAttemptId:X.optional(),hostReport:yx.optional(),failure:bx.optional()}).strict()).min(1),readyAt:F().datetime().optional(),expiresAt:F().datetime().optional(),endReason:xx.optional(),localSave:wx.optional()}).strict().superRefine((e,t)=>{(new Set(e.attempts.map(e=>e.attemptId)).size!==e.attempts.length||!e.attempts.some(t=>t.attemptId===e.currentAttemptId)||e.readyAt===void 0!=(e.expiresAt===void 0))&&t.addIssue({code:`custom`,message:`Download attempts and lifetime must identify one stored snapshot.`}),(e.endReason===`stored_locally`&&e.localSave?.status!==`saved`||e.endReason===`local_save_failed`&&e.localSave?.status!==`failed`||e.attempts.some(e=>e.hostReport===`unsupported`!=(e.failure!==void 0))||e.localSave&&(e.localSave.attemptId!==e.currentAttemptId||!e.attempts.some(t=>t.attemptId===e.currentAttemptId&&t.hostReport===`unsupported`)||e.localSave.status===`saving`&&e.endReason!==void 0||e.localSave.status===`saved`!=(e.endReason===`stored_locally`)))&&t.addIssue({code:`custom`,message:`Local saving requires the current download's unsupported report.`})});var Tx=W([`settings_retry_download`,`settings_report_download`,`settings_cancel_download`,`settings_store_backup`]),Ex=hc(`action`,[B({action:G(`settings_download_backup`),operationId:X,attemptId:X}).strict(),B({action:G(`settings_retry_download`),operationId:X,fileId:X,previousAttemptId:X,attemptId:X}).strict(),B({action:G(`settings_report_download`),operationId:X,fileId:X,attemptId:X,status:yx,failure:bx.optional()}).strict().refine(e=>e.status===`unsupported`==(e.failure!==void 0),`Only unsupported downloads require the exact method failure.`),B({action:G(`settings_store_backup`),operationId:X,fileId:X,attemptId:X,saveAttemptId:X,previousSaveAttemptId:X.optional(),allowPossibleCopy:L()}).strict(),B({action:G(`settings_cancel_download`),operationId:X,fileId:X,attemptId:X}).strict(),B({action:G(`settings_select`),draft:vx}).strict(),B({action:G(`settings_prepare`),operationId:X}).strict(),B({action:G(`settings_begin_upload`),operationId:X,name:F().min(1),totalSize:hx.max(mx),sha256:gx}).strict(),B({action:G(`settings_upload_chunk`),operationId:X,fileId:X,offset:hx.max(mx),chunkBase64:F()}).strict(),B({action:G(`settings_seal_upload`),operationId:X,fileId:X}).strict(),B({action:G(`settings_confirm`),operationId:X,preparationId:X}).strict(),B({action:G(`settings_back`),operationId:X}).strict(),B({action:G(`settings_cancel`)}).strict()]),Dx=B({outcome:W([`completed`,`failed`,`interrupted`,`superseded`]),recordedAt:F().datetime(),message:F().min(1),details:U(F(),R()).optional(),completionScope:G(`backup_snapshot`).optional()}).strict(),Ox=B({storedValue:F(),effectiveValue:F(),source:W([`environment`,`local_db`,`builtin_default`]),pendingStoredValue:F().optional(),appliesAfter:G(`mcp_server_restart`).optional()}).strict(),kx=B({endpoint:W([`grpc`,`graphql`]),key:W([`suiGrpcUrl`,`suiGraphqlUrl`]),value:F().min(1),status:W([`saved`,`reset`]),storedValue:F(),effectiveValue:F(),source:Ox.shape.source}).strict().refine(e=>e.key===(e.endpoint===`grpc`?`suiGrpcUrl`:`suiGraphqlUrl`),`The endpoint kind and preference key must agree.`),Ax=I().int().nonnegative().safe(),jx=B({accounts:Ax,reviewSessions:Ax,reviewStateSnapshots:Ax,reviewStatusTransitions:Ax,reviewExecutions:Ax,reviewRequests:Ax,outcomeUnknownRequests:Ax,externalActivityScans:Ax,externalActivityTransactions:Ax,localSettings:Ax}).strict(),Mx=B({status:G(`valid`),format:G(px),network:G(`mainnet`),exportedAt:F().datetime(),currentCounts:jx,incomingCounts:jx,willReplace:G(!0),activeAccountChange:W([`unchanged`,`set`,`cleared`]),currentReadAddress:d_.nullable(),incomingReadAddress:d_.nullable(),restartRequiredAfterImport:L()}).strict(),Nx=B({kind:G(`settings`),operationId:X,phase:W([`draft`,`uploading`,`sealed`,`prepared`,`executing`,`stopping`,`starting`,`terminal`]),draft:vx.optional(),preparationId:X.optional(),preparation:U(F(),R()).optional(),file:B({fileId:X,displayName:F(),totalSize:hx,receivedSize:hx,sha256:gx,sealed:L(),cleanup:W([`pending`,`complete`,`failed`])}).strict().optional(),download:B({availability:W([`preparing`,`available`,`ended`]),currentAttemptId:X,hostReport:yx.optional(),previousUnconfirmed:L(),endReason:xx.optional(),expiresAt:F().datetime().optional(),remainingMs:hx.optional(),localSave:B({status:W([`needs_consent`,`saving`,`saved`,`failed`]),currentSaveAttemptId:X.optional(),failure:Cx.optional(),savedAt:F().datetime().optional()}).strict().optional(),allowedFileActions:z(Tx)}).strict().optional(),restoreCheck:_x.optional(),backupLocation:B({directory:F().min(1),filename:F().min(1)}).strict().optional(),result:Dx.optional(),temporaryFileCleanup:W([`pending`,`complete`,`failed`]).optional(),priorRunId:X.optional(),nextRunId:X.optional(),supersedesOperationId:X.optional(),supersededByOperationId:X.optional(),allowedActions:z(W(Ex.options.map(e=>e.shape.action.value))),observe:L(),facts:B({server:B({name:F(),version:F(),network:G(`mainnet`)}).strict(),localSettings:B({suiGrpcUrl:Ox,suiGraphqlUrl:Ox}).strict(),readAddress:F().optional(),assetReadAccount:U_,walletAvailability:R_,connectionReconciliationRequired:G(!0).optional(),observedAt:F().datetime().optional(),counts:jx}).strict().optional()}).strict().superRefine((e,t)=>{if(e.download&&(e.draft?.kind!==`download_backup`||!e.file||e.download.availability===`available`&&(!e.file.sealed||!e.result||e.download.endReason||!e.download.expiresAt)||e.download.availability===`ended`&&!e.download.endReason)&&t.addIssue({code:`custom`,message:`Download delivery must describe its own snapshot and lifetime.`}),e.draft?.kind===`download_backup`&&e.preparation!==void 0&&t.addIssue({code:`custom`,message:`Private download preparation is not public preparation data.`}),e.restoreCheck&&(e.draft?.kind!==`import_local_data`||e.result)&&t.addIssue({code:`custom`,message:`Restore checks belong to an uncompleted import preparation.`}),e.restoreCheck?.status===`can_restore`&&(e.phase!==`prepared`||!e.file?.sealed||!e.allowedActions.includes(`settings_confirm`))&&t.addIssue({code:`custom`,message:`Restore availability requires a sealed file and current confirmation.`}),e.draft?.kind===`import_local_data`&&e.restoreCheck?.status!==`can_restore`&&e.allowedActions.includes(`settings_confirm`)&&t.addIssue({code:`custom`,message:`An unchecked or blocked import cannot offer confirmation.`}),e.restoreCheck?.status===`receiving`&&(!e.file||e.file.sealed||![`draft`,`uploading`].includes(e.phase))&&t.addIssue({code:`custom`,message:`Receiving requires the selected unsealed upload.`}),e.restoreCheck?.status===`check_required`&&(!e.file?.sealed||e.phase!==`sealed`)&&t.addIssue({code:`custom`,message:`A new check requires the same complete sealed upload.`}),e.restoreCheck?.status===`cannot_restore`&&e.restoreCheck.reason===`invalid_backup`&&(e.phase===`prepared`||e.allowedActions.includes(`settings_prepare`))&&t.addIssue({code:`custom`,message:`A rejected backup requires an explicit new selection.`}),e.backupLocation&&(e.result?.outcome!==`completed`||e.draft?.kind!==`export_local_data`&&(e.draft?.kind!==`download_backup`||e.download?.localSave?.status!==`saved`||e.download.endReason!==`stored_locally`))&&t.addIssue({code:`custom`,message:`A backup location requires its recorded successful export.`}),e.download?.localSave?.status===`saved`&&!e.backupLocation&&t.addIssue({code:`custom`,message:`A saved backup must identify its verified location.`}),e.draft?.kind===`export_local_data`&&e.result?.outcome===`completed`&&typeof e.result.details?.path==`string`&&!e.backupLocation&&t.addIssue({code:`custom`,message:`A recorded backup path must provide its folder and file name.`}),e.temporaryFileCleanup&&!e.result&&t.addIssue({code:`custom`,message:`Cleanup of an applied or ended operation requires its recorded result.`}),(e.phase===`terminal`!=(e.result!==void 0)||e.phase===`terminal`&&(e.observe||e.allowedActions.length))&&t.addIssue({code:`custom`,message:`A terminal Settings result cannot grant input or observation.`}),e.phase===`prepared`&&(!e.preparationId||!e.draft||!e.preparation)&&t.addIssue({code:`custom`,message:`Settings confirmation requires a prepared identity and facts.`}),e.phase===`prepared`&&e.draft?.kind===`import_local_data`&&!Mx.safeParse(e.preparation?.preview).success&&t.addIssue({code:`custom`,path:[`preparation`,`preview`],message:`Import confirmation requires the validated current and incoming read context and record counts.`}),e.phase===`prepared`&&(e.draft?.kind===`set_endpoint`||e.draft?.kind===`restore_endpoint`)){let n=kx.safeParse(e.preparation?.endpoint);(!n.success||n.data.endpoint!==e.draft.endpoint||n.data.status!==(e.draft.kind===`set_endpoint`?`saved`:`reset`)||e.draft.kind===`set_endpoint`&&n.data.value!==e.draft.value)&&t.addIssue({code:`custom`,path:[`preparation`,`endpoint`],message:`Endpoint confirmation must name its exact prepared target.`})}e.file&&e.file.receivedSize>e.file.totalSize&&t.addIssue({code:`custom`,message:`Received content exceeds the selected file.`})}),Px=65536;function Fx(e){return new TextEncoder().encode(JSON.stringify(e)).length}function Ix(e){let t=Px-Fx(e);return t>0?3*Math.floor(t/4):0}function Lx(e){if(!e||typeof e!=`object`)return;let t=structuredClone(e);if(t.method===`tools/call`&&t.params?.name===`ui_act_card`&&t.params.arguments?.input?.action===`settings_upload_chunk`)return t.id=2**53-1,t.params.arguments.revision=2**53-1,t.params.arguments.input.offset=mx,t.params.arguments.input.chunkBase64=``,Ix(t)}var Rx={uiOpenAccount:`ui_open_account`,uiOpenReceipt:`ui_open_receipt`,uiOpenChart:`ui_open_chart`,uiReadCard:`ui_read_card`,uiSubmitCard:`ui_submit_card`,uiActCard:`ui_act_card`,uiReadSettingsFile:`ui_read_settings_file`,sessionOpenReviewManagement:`session_open_review_management`,readGetServerStatus:`read_get_server_status`,readListSupportedProtocols:`read_list_supported_protocols`,readListDeepbookPools:`read_list_deepbook_pools`,readListDeepbookTokens:`read_list_deepbook_tokens`,readInspectDeepbookOrderbook:`read_inspect_deepbook_orderbook`,readGetDeepbookMidPrice:`read_get_deepbook_mid_price`,readGetDeepbookUsdcPriceHistory:`read_get_deepbook_usdc_price_history`,readGetDeepbookUsdcPriceAtTime:`read_get_deepbook_usdc_price_at_time`,readQuoteDeepbookAction:`read_quote_deepbook_action`,readQuoteDeepbookDisplayAmount:`read_quote_deepbook_display_amount`,readSummarizeDeepbookAccountInventory:`read_summarize_deepbook_account_inventory`,readSummarizeWalletAssets:`read_summarize_wallet_assets`,readClassifyWalletAssets:`read_classify_wallet_assets`,readListSettlementAssetGroups:`read_list_settlement_asset_groups`,readSummarizeSettlementAssetGroupParity:`read_summarize_settlement_asset_group_parity`,readPreviewIntentEvidence:`read_preview_intent_evidence`,readListReviewActivity:`read_list_review_activity`,readSummarizeReviewFunnel:`read_summarize_review_funnel`,readGetReviewSessionDetail:`read_get_review_session_detail`,readInspectSuiTransaction:`read_inspect_sui_transaction`,readScanSuiAccountActivity:`read_scan_sui_account_activity`,readSummarizeSuiActivityScan:`read_summarize_sui_activity_scan`,readScanSuiFunctionActivity:`read_scan_sui_function_activity`,readSummarizeSuiFunctionActivityScan:`read_summarize_sui_function_activity_scan`,readSummarizeSuiAccountActivity:`read_summarize_sui_account_activity`,readGetAccountAssetTimeline:`read_get_account_asset_timeline`,settingsCreateLocalSettingsSession:`settings_create_local_settings_session`,settingsGetLocalSettings:`settings_get_local_settings`,actionStartReview:`action_start_review`,actionCreateProposalReview:`action_create_proposal_review`,sessionOpenWalletConnectionCard:`session_open_wallet_connection_card`,sessionGetWalletConnectionCard:`session_get_wallet_connection_card`,sessionWaitWalletConnectionCard:`session_wait_wallet_connection_card`,sessionGetInteractionStatus:`session_get_interaction_status`,sessionGetReviewStatus:`session_get_review_status`,sessionGetExecutionResult:`session_get_execution_result`,sessionWaitExecutionResult:`session_wait_execution_result`,accountGetActiveAccount:`account_get_active_account`},zx=B({connectionId:F().min(1),pairingUri:F().startsWith(`wc:`),expiresAt:F().datetime()}).strict(),Bx=W([`account`,`receipt`,`chart`,`connect`,`review`,`settings`]),Vx=B({cardId:F().min(1),kind:Bx,state:W([`ready`,`running`,`closed`]),revision:I().int().nonnegative(),createdAt:F().datetime(),expiresAt:F().datetime(),input:U(F(),R()),data:R().optional(),reason:W([`completed`,`expired`,`failed`,`server_restarted`,`cancelled`]).optional(),error:F().optional()}).strict().extend({pollAfterMs:I().int().positive(),inputRemainingMs:I().int().nonnegative()}),Hx=B({transactionDigest:F().min(1),pureInputs:z(B({index:I().int().nonnegative(),bytes:F().regex(/^0x(?:[0-9a-f]{2})*$/i)}).strict()).refine(e=>new Set(e.map(e=>e.index)).size===e.length,`Duplicate input index.`),ptbGraph:B({mermaid:B({text:F(),namedText:F()}).strict()}).strict().optional()}).strict(),Ux=`sui-mcp/card`,Wx=`sui-mcp/receipt-display`,Gx=`sui-mcp/wallet-display`,Kx=`sui-mcp/settings-file`,qx=`suimcp://cards/`,Jx=hc(`kind`,[B({kind:G(`account`),status:G(`input_required`),field:G(`account`),message:F().min(1)}).strict(),B({kind:G(`receipt`),status:G(`input_required`),field:G(`digest`),message:F().min(1)}).strict()]),Yx=B({cardId:F().min(1),permission:F().min(1)}).strict();Yx.extend({revision:I().int().nonnegative(),input:U(F(),R())}).strict();var Xx=Hx.extend({cardId:F().min(1),revision:I().int().nonnegative(),attemptId:F().min(1).optional()}),Zx=zx.extend({cardId:F().min(1),revision:I().int().nonnegative()}),Qx=B({attemptId:F().uuid().optional(),cardId:F().min(1),operationId:F().uuid(),fileId:F().uuid(),offset:I().int().nonnegative().safe(),totalSize:I().int().nonnegative().safe(),sha256:F().regex(/^[a-f0-9]{64}$/),chunkBase64:F()}).strict(),$x={account:Rx.uiOpenAccount,receipt:Rx.uiOpenReceipt,chart:Rx.uiOpenChart,read:Rx.uiReadCard,submit:Rx.uiSubmitCard,act:Rx.uiActCard,readSettingsFile:Rx.uiReadSettingsFile};function Z(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function eS(e){return e.kind!==`import_local_data`}function tS(e,t,n){if(e.kind!==`settings`||t.kind!==`settings`||e.cardId!==t.cardId||t.state!==`ready`)return;let r=Nx.safeParse(e.data),i=Nx.safeParse(t.data);if(!r.success||!i.success)return;let a=r.data,o=i.data,s=o.draft;if(!s||!a.draft||a.operationId!==o.operationId||n.operationId!==o.operationId||JSON.stringify(a.draft)!==JSON.stringify(s))return;if(eS(s))return n.action===`settings_prepare`?{kind:`preparation_response`,cardId:t.cardId,operationId:o.operationId,draft:s}:void 0;let c=o.file?.fileId;if(!(!c||!a.file?.fileId||a.file.fileId!==c||n.action!==`settings_prepare`&&n.action!==`settings_seal_upload`||n.action===`settings_seal_upload`&&n.fileId!==c))return{kind:`backup_check_response`,cardId:t.cardId,operationId:o.operationId,fileId:c,action:n.action}}function nS(e){return Object.keys(e).filter(t=>e[t]!==void 0)}function rS(e,t){if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>rS(e,t[n]));let n=Z(e),r=Z(t);if(!n||!r)return!1;let i=nS(n);return i.length===nS(r).length&&i.every(e=>Object.hasOwn(r,e)&&rS(n[e],r[e]))}function iS(e,t=!0){let n=Z(e);if(!n)throw Error(`The app did not provide a usable card response.`);let r=()=>Error(`The app provided inconsistent card response information.`),i,a=e=>{let t=Z(e);if(!t||typeof t.ok!=`boolean`||i&&!rS(i,t))throw r();i=t};n.structuredContent!==void 0&&a(n.structuredContent);let o,s;if(Array.isArray(n.content))for(let e of n.content){let n=Z(e);if(n?.type!==`text`||typeof n.text!=`string`)continue;let i;try{i=Z(JSON.parse(n.text))}catch{continue}if(i){if(i.ok!==void 0)a(i);else if(Array.isArray(i.content)){if(!t||o)throw r();let n=Xu.safeParse(i);if(!n.success)throw r();o=iS(n.data,!1),s=e,o.structuredContent!==void 0&&a(o.structuredContent)}}}let c=Object.create(null),l=!1;for(let e of[n._meta,o?._meta]){if(e===void 0)continue;let t=Z(e);if(!t)throw r();for(let e of nS(t)){let n=t[e];if(Object.hasOwn(c,e)&&!rS(c[e],n))throw r();c[e]=n}l=!0}if(n.isError!==void 0&&typeof n.isError!=`boolean`||o?.isError!==void 0&&n.isError!==void 0&&o.isError!==n.isError||(n.isError===!0||o?.isError===!0)&&i?.ok===!0)throw r();return{...o,...n,...o?{content:[...Array.isArray(n.content)?n.content.filter(e=>e!==s):[],...Array.isArray(o.content)?o.content:[]]}:{},...i?{structuredContent:i}:{},...l?{_meta:c}:{}}}function aS(e,t){let n=Z(Z(e?.data)?.request);return!!e&&(e.kind===`receipt`||e.kind===`review`)&&t.cardId===e.cardId&&t.revision===e.revision&&t.transactionDigest===(e.kind===`receipt`?e.input.digest:n?.transactionDigest)&&(e.kind!==`review`||t.attemptId===n?.attemptId)}function oS(e){let t;for(let n of Array.isArray(e.content)?e.content:[]){let e=Z(n),r;if(e?.type===`resource_link`&&typeof e.uri==`string`&&e.uri.startsWith(`suimcp://cards/`)&&(r=e.uri),e?.type===`text`&&typeof e.text==`string`){let t=/^\[Resource link: card_([A-Za-z0-9_-]+)\] (suimcp:\/\/cards\/([A-Za-z0-9_-]+)) \(Saved data for this exact card\.\)$/.exec(e.text);if(!t&&e.text.startsWith(`[Resource link:`)&&e.text.includes(`suimcp://cards/`))throw Error(`The saved card links could not be matched to one card.`);if(t){if(t[1]!==t[3])throw Error(`The saved card links could not be matched to one card.`);r=t[2]}}if(r===void 0)continue;let i=r.slice(qx.length);if(!i||encodeURIComponent(i)!==i||t!==void 0&&i!==t||e?.type===`resource_link`&&typeof e.name==`string`&&e.name.startsWith(`card_`)&&e.name!==`card_${i}`)throw Error(`The saved card links could not be matched to one card.`);t=i}return t}function sS(e){let t=Z(e.structuredContent),n=t?.ok===!0?Jx.safeParse(t.data):void 0,r=Z(Z(t?.error)?.details),i=n?.success?void 0:t?.ok===!0?Z(t.data)?.card??t.data:r?.snapshot,a=i===void 0?void 0:Vx.parse(i);a?.kind===`settings`&&Nx.parse(a.data);let o=Z(e._meta)?.[Wx],s=o===void 0?void 0:Xx.parse(o);if(s&&!aS(a,s))throw Error(`Transaction details do not match this saved result.`);let c=Z(e._meta)?.[Gx],l=c===void 0?void 0:Zx.parse(c);if(l&&(!a||a.kind!==`connect`||l.cardId!==a.cardId||l.revision!==a.revision||l.connectionId!==Z(Z(a.data)?.connection)?.connectionId))throw Error(`The connection QR code does not match this card.`);return{snapshot:a,display:s,wallet:l,inputRequired:n?.success?n.data:void 0,error:typeof r?.message==`string`?r.message:typeof r?.reason==`string`?r.reason:void 0}}function cS(e,t){let n=document.getElementById(`app`);if(!n)throw Error(`Card root is unavailable.`);let r=document.createElement(`h1`);r.textContent=t.title;let i=document.createElement(`p`);i.className=`ui-note`,i.setAttribute(`role`,`status`);let a=document.createElement(`p`);a.className=`ui-error`,a.setAttribute(`role`,`alert`);let o=document.createElement(`p`);o.className=`ui-note card-guidance`;let s=document.createElement(`section`),c=document.createElement(`div`);c.className=`card-actions`;let l=document.createElement(`div`);l.className=`card-progress-hint`,l.hidden=!0,n.replaceChildren(r,i,a,s,o,l,c);let u=new Zh({name:`sui-mcp-card`,version:`0.7.0`},{},{autoResize:!0,strict:!0}),d=new AbortController,f=e===`connect`||e===`review`,p=e===`settings`,m=f||p,h=!1,g,_,v,y,b,ee,x,te=!1,ne=!1,re,ie,S={status:`unconfirmed`},ae,oe,se,C,w,T=`continue`,E,ce,le=0,ue=0,de,fe,pe,me,D,he,ge,_e,ve=!1;function ye(){if(!C||!y)return;let{input:e,basis:t}=C,n=Z(y.data),r=Z(t.data),i=Z(n?.request),a=Z(n?.review),o=Z(n?.connection),s=Z(r?.request),c=Z(r?.connection),l=!!i&&i.attemptId===s?.attemptId,u=!!o&&o.connectionId===c?.connectionId;if(!f)return y.state===`running`||y.reason===`completed`?C.delivery===`rejected`?`past`:`observed`:y.state===`closed`?`past`:`active`;if(e.walletRunId&&e.walletRunId!==Z(n?.walletAvailability)?.walletRunId&&e.walletRunId!==n?.acceptedWalletRunId)return`past`;switch(e.action){case`connect`:if(y.state!==`ready`&&o)return`observed`;if(n?.walletAvailability&&Z(n.walletAvailability)?.status===`available`&&Array.isArray(n.connections)&&n.connections.some(e=>Z(e)?.status===`connected`))return`past`;break;case`prepare_review`:if(typeof a?.reviewRevision==`number`&&typeof e.reviewRevision==`number`&&a.reviewRevision>e.reviewRevision)return a.account===e.account?`observed`:`past`;break;case`request_signature`:if(i?.account===e.account&&i?.reviewRevision===e.reviewRevision)return`observed`;if(typeof a?.reviewRevision==`number`&&typeof e.reviewRevision==`number`&&a.reviewRevision>e.reviewRevision||!i&&a&&a.reviewRevision===e.reviewRevision&&a.account===e.account&&a.status===`refresh_required`&&Z(a.state)?.refreshReason===`review_evidence_stale`&&Array.isArray(n?.allowedActions)&&n.allowedActions.includes(`prepare_review`))return`past`;break;case`cancel`:if(y.reason===`cancelled`)return`observed`;break;case`disconnect`:if(o&&o.connectionId===e.connectionId&&(o.pendingAction===`disconnect`||y.state!==`ready`&&o.status===`disconnected`))return`observed`;break;case`use_account`:if(y.reason===`completed`&&n?.activeAccount===e.account&&o?.connectionId===e.connectionId)return`observed`;break;case`stop_connection`:if(u&&o?.status===`stopped`)return`observed`;if(u&&o?.status!==`awaiting_approval`)return`past`;break;case`stop_waiting`:if(l&&(i?.requestStatus===`stopped`||n?.observationStopped===!0))return`observed`;if(l&&[`completed`,`request_failed`,`outcome_unknown`].includes(String(i?.requestStatus)))return`past`;break;case`read_result`:if(l&&(n?.observe===!0||i?.requestStatus===`completed`))return`observed`;if(l&&[`stopped`,`request_failed`].includes(String(i?.requestStatus)))return`past`}return be()||typeof n?.actionRemainingMs==`number`&&n.actionRemainingMs<=0||[`connect`,`disconnect`,`use_account`,`cancel`,`prepare_review`,`request_signature`].includes(String(e.action))&&(y.state!==`ready`||a?.status===`expired`)?`past`:`active`}function be(){let e=lx.safeParse(C?.input);if(!e.success||e.data.action!==`disconnect`&&e.data.action!==`use_account`)return!1;let t=e.data,n=dx.safeParse(y?.data);if(!n.success)return!1;let r=n.data.connections.find(e=>e.connectionId===t.connectionId);return r?t.action===`disconnect`?n.data.walletAvailability.status===`available`&&!r.pendingAction&&!n.data.manageableConnectionIds.includes(t.connectionId)&&[`disconnected`,`failed`,`rejected`,`stopped`,`expired`].includes(r.status):[`disconnected`,`failed`,`rejected`,`stopped`,`expired`].includes(r.status)||t.action===`use_account`&&r.status===`connected`&&!r.accounts.includes(t.account):!1}function xe(){if(!C)return;let e=ye();e&&C.disposition!==`observed`&&(e!==`active`||C.disposition===`active`)&&(C.disposition=e),C.disposition===`observed`&&(C.retryRequired=!1)}function Se(){let e=ux.safeParse(Z(y?.data)?.automaticAction);return C?.retryRequired&&e.success&&C.input.action===e.data.action?e.data:void 0}function Ce(e){let t={connect:`connection request`,prepare_review:`review update`,request_signature:`wallet approval request`,read_result:`transaction status check`,cancel:`cancellation request`,stop_connection:`request to stop connecting`,stop_waiting:Z(Z(e.basis.data)?.request)?.requestStatus===`awaiting_signature`?`request to stop wallet approval`:`request to stop checking the result`,disconnect:`wallet disconnect request`,use_account:`account selection`};return f?t[String(e.input.action)]??`request`:`data request`}function we(e){if(e!==`past`||!C)return;let t=Ce(C),n=C.input.action===`read_result`&&Z(Z(y?.data)?.request)?.requestStatus===`outcome_unknown`?` To check this transaction again, ask to open its result in chat.`:``;return`Message from an earlier ${t}: “${C.message}”${n}`}let Te,Ee;function De(){let t=Z(y?.data),n=p?Z(t?.download):void 0,r=Array.isArray(n?.allowedFileActions)?n.allowedFileActions:[],i=[...Array.isArray(t?.allowedActions)?t.allowedActions:[],...r.filter(e=>e===`settings_report_download`||Te===void 0||Date.now()<Te)],a=e===`review`&&t?.mode===`review`&&!t.request&&!!g&&y?.state===`ready`,o=a&&de!==void 0&&Date.now()>=de,s=document.visibilityState!==`hidden`,c=d.signal.aborted||S.status===`rejected`,l=S.status===`confirmed`,u=C?.disposition,v=u===`active`,b=C?.retryRequired===!0,ee=C?.input.action===`request_signature`&&u===`active`,x=T===`paused`,ne=he?.pending?.()===!0,re=he?.displayRecovery?.(),le=l&&!c&&!oe&&!ne&&!o&&!!g,fe=le&&!w&&!h&&(!m||!(E&&(v||b||x))),pe=ux.safeParse(t?.automaticAction),me=p?Z(n?.localSave):void 0,D=!!y&&(m?t?.observe===!0||me?.status===`saving`:y.state===`running`),ge=!!_&&te&&!c&&!E&&s&&(ce===`explicit`||S.status!==`read_failed`&&(ce===`background`||S.status===`needed`&&S.automatic)),_e=s&&le&&!ae&&!E&&!ce&&!w&&!b&&!ee&&!x&&f&&pe.success&&i.includes(pe.data.action)?pe.data:void 0,ve=Z(t?.restoreCheck),ye=p&&le&&y?.state===`ready`&&!w&&!h&&!t?.result&&t?.observe!==!0&&(ve?.status===`cannot_restore`&&[`operation_busy`,`wallet_request_unsettled`].includes(String(ve.reason))||!i.includes(`settings_select`)||!i.includes(`settings_download_backup`)||t?.phase===`prepared`&&!i.includes(`settings_confirm`)||t?.phase===`draft`&&Z(t.draft)?.kind!==void 0&&Z(t.draft)?.kind!==`import_local_data`&&!i.includes(`settings_prepare`)),be;!c&&_&&(S.status===`read_failed`||ae||S.status===`unconfirmed`?be=`read`:S.status===`needed`?S.automatic||(be=`read`):oe||re||p&&[`pending`,`failed`].includes(String(t?.temporaryFileCleanup))||me?.status===`saving`||me?.status===`needs_consent`&&!i.includes(`settings_store_backup`)||me?.status===`failed`&&me.failure===`not_published`&&!n?.endReason&&!i.includes(`settings_store_backup`)||ye?be=`read`:g?Z(t?.progress)?.status===`unavailable`||Z(t?.walletAvailability)?.status===`initializing`&&Z(t?.walletAvailability)?.stage===`state_sync`?be=`read`:!x&&Se()?be=`retry`:v&&!D&&!(x&&i.length>0)&&!(C?.input.action===`prepare_review`&&i.includes(`prepare_review`)&&t?.automaticAction===void 0)&&f&&(be=`read`):(y?.state!==`closed`||oe)&&(be=`read`));let xe=f?t?.actionRemainingMs:y?.inputRemainingMs;be===`retry`&&o&&(be=`read`);let Ee=f?t?.nextStateReadAfterMs:p&&Te!==void 0?Math.max(0,Te-ue):void 0,De=[(f?i.length>0:y?.state===`ready`)?xe:void 0,Ee].filter(e=>typeof e==`number`&&Number.isFinite(e)&&e>0),Oe=!c&&!!g&&s&&!ie&&!ae&&S.status!==`read_failed`,ke=Z(t?.review),Ae=a&&!c&&!ae&&!oe&&!v&&!b&&!x&&S.status!==`read_failed`&&(ne||w?.input.action===`prepare_review`||ke?.preparing===!0||pe.success&&pe.data.action===`prepare_review`||S.status===`needed`&&ke?.status===`ready_for_wallet_review`);return{current:l,inputEnabled:fe,permitted:i,disposition:u,read:ge,auto:_e,recover:be,paused:x,partialDisplayFailure:re,settingsInputBlocked:ye,reviewUpdatePending:Ae,reviewCommandDeliveryFailed:v&&C?.input.action===`prepare_review`,reviewHint:o?void 0:Ae?ne||ke?.preparing||w?.input.action===`prepare_review`?`Updating review…`:`Checking status…`:a&&Z(ke?.state)?.refreshReason===`review_evidence_stale`?`Review details are out of date.`:void 0,errors:[S.status===`rejected`?S.message:S.status===`read_failed`?`This card's status could not be checked. Reported message: “${S.message}”`:void 0,ae&&S.status!==`rejected`?`This card could not be opened. Reported message: “${ae}”`:void 0,v&&C?`Message for this ${Ce(C)}: “${C.message}”`:void 0,oe,re?.message],note:[se,we(u)].filter(Boolean).join(` `),expiryAt:Oe&&l&&De.length?ue+Math.min(...De):void 0,poll:Oe&&(D||S.status===`needed`&&!S.automatic),lifetimeAt:!c&&s&&a?de:void 0}}function Oe(e){return e.recover===`retry`?C?.input.action===`connect`?`Retry connection`:`Retry review`:e.recover===`read`?`Check status`:void 0}function ke(e){if(d.signal.aborted)return``;let n=e.errors.some(Boolean)||e.recover!==void 0||!!y&&!g&&y.state!==`closed`||y?.state===`closed`&&y.reason!==`completed`,r=e.errors.some(Boolean)||S.status!==`confirmed`||e.recover===`retry`||e.settingsInputBlocked;if(n&&r&&S.status!==`rejected`){if(E||e.read)return`Checking status…`;let t=Oe(e);if(t)return t===`Check status`?oe||e.partialDisplayFailure?`Use Check status to read this card and try displaying it again.`:`Use Check status to read this card again.`:t===`Retry connection`?`Use Retry connection to try connecting your wallet again.`:`Use Retry review to try again with the displayed wallet and account.`;if(Ae(e)&&he?.selectionHint)return he.selectionHint}return t.guidance?.(y,{confirmed:e.current,readOnly:!g,recoveryNeeded:n,visibleConfirmation:he?.visibleConfirmation?.(),commandPending:m&&w&&e.current&&!e.errors.some(Boolean)&&(w.phase===`confirming`||y?.state===`ready`&&!Z(y.data)?.runtimeRecovery&&!Z(y.data)?.request&&!Z(Z(y.data)?.review)?.preparing)?{phase:w.phase,action:String(w.input.action)}:void 0,approvalUnresolved:C?.input.action===`request_signature`&&e.disposition===`active`||w?.input.action===`request_signature`,automaticPaused:e.paused})??``}function Ae(e=De()){return e.inputEnabled&&y?.state===`ready`&&ve}function je(e,t=De()){return m&&t.inputEnabled&&(e?t.permitted.includes(e.action):t.permitted.length>0)}function Me(e){let t=De();return p&&h&&t.current&&!!g&&!w&&!E&&!oe&&!d.signal.aborted&&[`settings_begin_upload`,`settings_upload_chunk`,`settings_seal_upload`,`settings_retry_download`,`settings_report_download`,`settings_cancel_download`,`settings_store_backup`].includes(String(e.action))&&t.permitted.includes(e.action)}function Ne(e){let u=Z(y?.data),f=s.querySelector(`.review-action-feedback`),_=s.querySelector(`.review-primary-action`);if(_&&f){let e=s.querySelector(`.review-lifetime`);e?(e.append(l),f.prepend(a)):f.prepend(l,a),f.append(o)}else n.insertBefore(a,s),n.insertBefore(l,c),n.insertBefore(o,l);a.className=_?`ui-note`:`ui-error`,y?(r.textContent=t.titleFor?.(y)??t.title,i.textContent=S.status===`rejected`?`Card unavailable`:!e.current&&y.state===`ready`?_?``:!d.signal.aborted&&(E||e.read)?`Checking whether actions are available in this card…`:`Actions are unavailable until this card's status is checked.`:!g&&y.state!==`closed`?`View only.`:m?Z(u?.progress)?.status===`unavailable`?`Current progress is unavailable. The last recorded state is shown.`:!u?.request&&y.state===`closed`&&[`expired`,`server_restarted`,`cancelled`].includes(y.reason??``)?`This card no longer accepts actions.`:``:y.state===`running`?`Reading the requested data…`:y.reason===`completed`?``:y.error??(y.reason===`expired`?`The time to make a selection has ended.`:y.reason===`server_restarted`?`This request ended when Sui MCP restarted.`:``)):i.textContent=ie?``:S.status===`read_failed`?`Card status unavailable`:ae||S.status===`rejected`?`Card unavailable`:`Opening card…`,i.hidden=!i.textContent,a.textContent=[...new Set(e.errors.filter(Boolean))].join(` `),a.hidden=!a.textContent;let v=s.querySelector(`.review-status`);v&&(v.hidden=!!_&&(e.reviewUpdatePending||!!a.textContent));let b=s.querySelector(`.review-material-status`);if(b&&(b.textContent=b.dataset.previous===`true`||!e.current||e.reviewUpdatePending?b.dataset.previousLabel??``:b.dataset.currentLabel??``),o.textContent=[e.note,ke(e)].filter(Boolean).join(` `),o.hidden=!o.textContent,ve)for(let t of s.querySelectorAll(`input, button, select`))(!m||t.tagName!==`BUTTON`||t.dataset.cardAction!==void 0)&&(t.disabled=m?!je(void 0,e):!Ae(e));if(m)for(let t of s.querySelectorAll(`[data-card-action]`))t.disabled=!je({action:t.dataset.cardAction},e);if(p)for(let t of s.querySelectorAll(`[data-settings-file-action]`))t.disabled=t.dataset.settingsLocalBlocked===`true`||!(h?Me({action:t.dataset.cardAction}):je({action:t.dataset.cardAction},e));_&&(e.reviewUpdatePending||_.dataset.cardAction===`request_signature`&&e.reviewCommandDeliveryFailed||_.dataset.cardAction===void 0)&&(_.disabled=!0),D&&(D.disabled=!!w||!!E)}function Pe(e){try{e?.()}catch{oe=`The card display could not be closed cleanly. Its stored information is unchanged.`}}function Fe(e){if(!y||d.signal.aborted)return;if(y.state===`ready`&&S.status!==`confirmed`){if(p&&he?.update)try{he.update(y,{automaticPaused:T===`paused`,settings:qe,settingsCommandProgress:void 0,onDisplayChange:()=>k()})}catch{oe=`This card could not be displayed. Its stored information is unchanged.`}return}if(y.state===`running`&&!m){oe=void 0;return}let n=m?{...Z(y.data),actionRemainingMs:void 0,nextStateReadAfterMs:void 0,...p&&Z(y.data)?.download?{download:{...Z(Z(y.data)?.download),remainingMs:void 0}}:{}}:void 0,r=p&&w?.phase===`sending`&&S.status===`confirmed`?tS(w.basis,y,w.input):void 0,i=`${T===`paused`}:${JSON.stringify(r)}:${y.revision}:${g!==void 0}:${b!==void 0}:${x!==void 0}:${JSON.stringify(n)}`;if(i===ge||i===_e&&!e)return;_e=i;let a=[...s.children],o=new Set([...s.querySelectorAll(`details`)].filter(e=>e.open).map(e=>e.querySelector(`summary`)?.textContent)),c,l=!1,u=!1;try{let e={automaticPaused:T===`paused`,onDisplayChange:()=>k(),...p?{settings:qe,settingsCommandProgress:r}:{}};if(he?.update?.(y,e)){ge=i,oe=void 0;return}if(y.state===`ready`&&g){let n=t.controls(y,e=>{Ge(e)},b,x,e);c=`node`in n?n:{node:n},l=!0}else(m||y.reason===`completed`)&&y.data!==void 0&&(c=t.result(y,b,g?e=>{Ge(e)}:void 0,x,e));s.replaceChildren(...c?[c.node]:[]),u=!0,c?.mount?.();for(let e of s.querySelectorAll(`details`))o.has(e.querySelector(`summary`)?.textContent)&&(e.open=!0)}catch{u&&s.replaceChildren(...a),Pe(c?.dispose),oe=`This card could not be displayed. Its stored information is unchanged.`;return}let f=he?.dispose;he=c,ve=l,ge=i,oe=void 0,Pe(f)}function Ie(t,n,r,i,a){if(d.signal.aborted||S.status===`rejected`)return!1;if(t.kind!==e||t.cardId!==_)throw S={status:`rejected`,message:`The returned information does not match this card.`},Error(`The returned information does not match this card.`);let o=Z(t.data),s=Z(o?.request),c=Z(s?.execution),l=o?.automaticAction===void 0?void 0:ux.safeParse(o.automaticAction);if(l&&!l.success)throw Error(`This card could not start the next step.`);if(y&&t.revision<y.revision)return!1;if(v&&[...new Set([...Object.keys(v),...Object.keys(t.input)])].some(e=>JSON.stringify(t.input[e])!==JSON.stringify(v[e])))throw S={status:`rejected`,message:`The returned information does not match this card.`},Error(`The returned information does not match this card.`);if(e===`review`&&(Z(o?.review)?.reviewSessionId!==void 0&&Z(o?.review)?.reviewSessionId!==t.input.reviewSessionId||s&&(s.reviewSessionId!==t.input.reviewSessionId||t.input.attemptId!==void 0&&s.attemptId!==t.input.attemptId)||c&&(c.reviewSessionId!==s?.reviewSessionId||c.attemptId!==s?.attemptId||c.txDigest!==s?.transactionDigest)||Z(o?.receipt)?.status===`found`&&Z(Z(o?.receipt)?.receipt)?.txDigest!==s?.transactionDigest)||e===`receipt`&&o?.status===`found`&&Z(o.receipt)?.txDigest!==t.input.digest)throw S={status:`rejected`,message:`The saved result does not match the information requested in this card.`},Error(S.message);!v&&(f||t.state!==`ready`)&&(v={...t.input});let u=r!==`preview`;if((!y||t.revision!==y.revision)&&(b=void 0,x=void 0),y=t,xe(),u){ue=Date.now();let t=p?Z(o?.download):void 0;if(t?.availability===`available`&&typeof t.remainingMs==`number`&&Number.isFinite(t.remainingMs)){let e=`${o?.operationId}:${Z(o?.file)?.fileId}:${t.expiresAt}`;Ee!==e&&(Ee=e,Te=void 0),Te=Math.min(Te??1/0,ue+Math.max(0,t.remainingMs))}else p&&t?.availability===`ended`&&(Te=void 0);g&&e===`review`&&o?.mode===`review`&&!o.request&&typeof o.actionRemainingMs==`number`&&Number.isFinite(o.actionRemainingMs)&&o.actionRemainingMs>=0&&(de=Math.min(de??1/0,ue+o.actionRemainingMs))}return r===`read`&&(S.status!==`needed`||a>S.afterRead)&&(S={status:`confirmed`},ae=void 0),n&&(b=n),x=i,!0}function Le(){fe!==void 0&&clearTimeout(fe),pe!==void 0&&clearTimeout(pe),me!==void 0&&clearTimeout(me),fe=void 0,pe=void 0,me=void 0,l.hidden=!0}function Re(e){let t=Oe(e);D?.textContent!==t&&(D?.remove(),D=void 0,t&&(D=eg(t,()=>{if(!(E||w||d.signal.aborted)){if(De().recover===`retry`){let e=Se();e&&We(e)}else O()}})));let n=s.querySelector(`.review-primary-action`),r=s.querySelector(`.review-primary-slot`);n&&(n.hidden=!!D&&!!r),D&&(D.disabled=!!E||!!w,r?(D.classList.add(`review-recovery-action`),r.append(D)):(D.classList.remove(`review-recovery-action`),c.append(D)))}async function O(){let e=he,t=e?.displayRecovery?.(),n=await Be(!0);n?.kind===`accepted`&&y===n.snapshot&&S.status===`confirmed`&&!d.signal.aborted&&document.visibilityState!==`hidden`&&!oe&&e===he&&t&&e?.displayRecovery?.()===t&&(t.retry(),k())}function k(e=!1){if(ie){let e=document.createElement(`p`);e.className=`ui-note`,e.textContent=ie,s.replaceChildren(e)}else Fe(e);let t=De();if(Ne(t),Le(),Re(t),d.signal.aborted||S.status===`rejected`)return;t.expiryAt!==void 0&&(pe=setTimeout(()=>{ze(),k()},Math.max(0,t.expiryAt-Date.now()))),t.reviewHint&&!a.textContent&&(l.replaceChildren(),l.textContent=t.reviewHint,l.setAttribute(`role`,`status`),l.hidden=!1);let n=s.querySelector(`.review-time-remaining`);if(n&&t.lifetimeAt!==void 0){let e=t.lifetimeAt,r=()=>{if(d.signal.aborted)return;let t=Math.max(0,e-Date.now()),i=Math.ceil(t/1e3);if(n.textContent=t>0?`Review expires in ${Math.floor(i/60)}:${String(i%60).padStart(2,`0`)}`:`Review time elapsed`,t>0)me=setTimeout(r,Math.min(1e3,t));else{let e=De();Ne(e),Re(e)}};r()}if(t.poll&&y){let e=ue+y.pollAfterMs-Date.now();fe=setTimeout(()=>{Be(!1)},e>0?e:y.pollAfterMs)}t.read?(ce=void 0,Ve()):t.auto&&(fe=setTimeout(()=>{let e=De().auto;e&&Ke(e,`automatic`)},0))}function ze(){S.status!==`rejected`&&S.status!==`read_failed`&&(S={status:`needed`,afterRead:le,automatic:!0})}function Be(e){return d.signal.aborted||S.status===`rejected`||!_||!te?Promise.resolve(void 0):E?E.promise:S.status===`read_failed`&&!e?Promise.resolve(void 0):(ce=e?`explicit`:`background`,k(),E?.promise??Promise.resolve(void 0))}function Ve(){let e=++le,t=performance.now(),n={id:e,promise:Promise.resolve().then(async()=>{try{let n,r,i;if(g){let e=sS(await He($x.read,g));if(!e.snapshot)throw Error(e.error??`Saved card data is unavailable.`);if(e.error)throw Error(e.error);n=e.snapshot,r=e.display,i=e.wallet}else{let e=`${qx}${encodeURIComponent(_)}`,t=(await u.readServerResource({uri:e},{signal:d.signal})).contents.find(t=>t.uri===e&&`text`in t);if(!t||!(`text`in t))throw Error(`Saved card data is unavailable.`);n=Vx.parse(JSON.parse(t.text));let i=b??ee;r=i&&aS(n,i)?i:void 0}if(d.signal.aborted||S.status===`rejected`)return{kind:`disposed`,id:e};let a=Ie(n,r,`read`,i,e);return ee=void 0,!a&&S.status===`needed`&&e>S.afterRead&&(S={...S,automatic:!1}),k(a),a&&S.status===`confirmed`?{kind:`accepted`,snapshot:n,id:e,requestStartedAt:t}:{kind:`ignored`,id:e}}catch(t){return d.signal.aborted?{kind:`disposed`,id:e}:(S.status!==`rejected`&&(S={status:`read_failed`,message:t instanceof Error?t.message:`Saved card data could not be read. The last displayed result is unchanged.`}),{kind:`failed`,id:e})}}).finally(()=>{E===n&&(E=void 0),k()})};E=n,k()}async function He(e,t){return iS(await u.callServerTool({name:e,arguments:t},{signal:d.signal}))}function Ue(e,t,n){let r=dx.safeParse(n.data);if(!r.success||!r.data.allowedActions.some(t=>t===e.action))return!1;let i=r.data,a=Z(t.data);return e.walletRunId&&e.walletRunId!==i.walletAvailability.walletRunId?!1:e.action===`connect`?i.allowedActions.includes(`connect`)&&[`connect`,`manage`].includes(String(n.input.intent)):e.action===`prepare_review`||e.action===`request_signature`?i.review?.reviewRevision===e.reviewRevision&&(e.action===`prepare_review`?i.assetReadAccount?.status===`available`?i.assetReadAccount.account:void 0:i.review?.account)===e.account&&fx(i,String(e.account),e.action===`request_signature`).some(t=>t.connectionId===e.connectionId):e.action===`disconnect`?i.manageableConnectionIds.includes(String(e.connectionId))&&i.connections.some(t=>t.connectionId===e.connectionId&&!t.pendingAction):e.action===`use_account`?i.connections.some(t=>t.connectionId===e.connectionId&&t.status===`connected`&&!t.pendingAction&&t.connectionId===i.usableConnectionId&&t.accounts.includes(String(e.account))):i.connection?.connectionId===Z(a?.connection)?.connectionId&&i.request?.attemptId===Z(a?.request)?.attemptId&&i.review?.reviewRevision===Z(a?.review)?.reviewRevision}async function We(e){if(!y||E||!je(e))return;let t={input:e,basis:y,phase:`confirming`};w=t;let n=await Be(!1);w===t&&(w=void 0,n?.kind===`accepted`&&y===n.snapshot&&S.status===`confirmed`&&!d.signal.aborted&&document.visibilityState!==`hidden`&&Ue(e,t.basis,n.snapshot)&&je(e)?await Ke(e):S.status!==`read_failed`&&S.status!==`rejected`&&!d.signal.aborted&&(se=`The card state changed. Check the current selection before trying again.`),k())}async function Ge(e){f&&(C?.disposition===`active`||C?.retryRequired||T===`paused`)?await We(e):await Ke(e)}function A(e,t,n){C={input:e.input,basis:e.basis,message:t,delivery:n,disposition:`active`,retryRequired:e.input.action===`connect`||e.input.action===`prepare_review`},xe(),[`cancel`,`disconnect`,`stop_connection`,`stop_waiting`,`use_account`].includes(String(e.input.action))&&(T=`paused`),(m||n===`unknown`)&&ze()}async function Ke(e,t=`user`){if(!y||!g||(t===`file`?!Me(e):m?!je(e):!Ae()))return;let n={input:e,basis:y,phase:`sending`};w=n,T=`continue`,(t===`user`||C?.disposition!==`past`)&&(C=void 0),se=void 0,k();try{let t=sS(await He(m?$x.act:$x.submit,{...g,revision:n.basis.revision,input:e}));if(d.signal.aborted||S.status===`rejected`)return;if(!t.snapshot)throw Error(t.error??`The request could not be confirmed.`);t.error&&A(n,t.error,`rejected`),Ie(t.snapshot,t.display,`action`,t.wallet)}catch(e){!d.signal.aborted&&S.status!==`rejected`&&(A(n,e instanceof Error?e.message:`The request could not be confirmed.`,`unknown`),C&&(C.data=Z(e)?.data))}finally{w===n&&(w=void 0),k()}}let qe={uploadChunkLimit(e,t){return g?Lx({jsonrpc:`2.0`,id:2**53-1,method:`tools/call`,params:{name:$x.act,arguments:{...g,revision:2**53-1,input:{action:`settings_upload_chunk`,operationId:e,fileId:t,offset:2**53-1,chunkBase64:``}}}})??0:0},async readCurrent(){let e=await Be(!0);if(e?.kind!==`accepted`)throw Error(`The current Settings selection could not be checked. Use Check status before continuing.`);return{snapshot:e.snapshot,requestStartedAt:e.requestStartedAt}},async act(e,t=!1){if(t?!Me(e):!je(e))throw Error(`This Settings action is unavailable until its current status has been checked.`);if(await Ke(e,t?`file`:`user`),d.signal.aborted)throw Error(`This card closed before the request finished. Reopen the same conversation to check its status.`);if(C?.input===e){let e=Error(C.message);throw e.data=C.data,e}if(!y)throw Error(`The current Settings status could not be checked.`);return y},setFileTransferActive(e){h=e,k()},async readFile(e){if(!g||!_||!De().current||d.signal.aborted)throw Error(`Backup read permission is unavailable.`);let t=await He($x.readSettingsFile,{...g,...e}),n=Qx.parse(Z(t._meta)?.[Kx]);if(n.cardId!==_||n.operationId!==e.operationId||n.fileId!==e.fileId||n.offset!==e.offset||n.attemptId!==e.attemptId)throw Error(`The backup response does not match this card's selected file.`);return n},download:async(e,t,n)=>{let r=Z(Z(y?.data)?.download);if(!g||!De().current||d.signal.aborted||document.visibilityState===`hidden`||r&&(r.currentAttemptId!==n||r.localSave||r.availability!==`available`||Te===void 0||Date.now()>=Te))throw Error(`This download is no longer available in this card.`);try{return{isError:(await u.downloadFile({contents:[{type:`resource`,resource:{uri:`file:///${encodeURIComponent(e)}`,mimeType:`application/json`,blob:t}}]},{signal:d.signal})).isError}}catch(e){if(e&&typeof e==`object`&&`code`in e&&e.code===-32601)return{unsupported:!0};throw e}}};async function Je(){if(te&&re!==void 0&&!ne){ne=!0;try{let t=iS(re),n=Z(t._meta);if(t._meta!==void 0&&!n)throw Error(`This card cannot accept actions with the access information provided by the app.`);let r=n?.[Ux];if(r!==void 0){let e=Yx.safeParse(r);if(!e.success)throw Error(`This card cannot accept actions with the access information provided by the app.`);g=e.data}let i=sS(t);if(i.inputRequired){if(i.inputRequired.kind!==e||g)throw Error(`The app provided inconsistent card input information.`);ie=i.inputRequired.message,k();return}let a=oS(t),o=[i.snapshot?.cardId,g?.cardId,a].filter(e=>e!==void 0);if(!o.length)throw Error(`Card data is unavailable.`);if(o.some(e=>e!==o[0])||i.snapshot&&i.snapshot.kind!==e)throw S={status:`rejected`,message:`The returned information does not match this card.`},Error(S.message);_=o[0];let s=i.snapshot;s&&(f||s.state!==`ready`)&&(v={...s.input}),ee=i.display,s&&g&&Ie(s,i.display,`preview`,i.wallet),ze(),k()}catch(e){if(d.signal.aborted)return;ae=e instanceof Error?e.message:`Card data could not be read.`,k()}}}u.ontoolresult=e=>{if(re===void 0)re=e,Je();else try{let t=sS(iS(re)).snapshot??y,n=sS(iS(e)).snapshot;if(t&&n&&(t.cardId!==n.cardId||t.kind!==n.kind))throw Error(`The app returned a different card.`)}catch{S={status:`rejected`,message:`The returned information does not match this card.`},k()}},u.onhostcontextchanged=e=>{e.theme&&(document.documentElement.dataset.theme=e.theme)};let Ye=()=>{document.visibilityState!==`hidden`&&g&&ne&&S.status!==`read_failed`?Be(!1):k()};document.addEventListener?.(`visibilitychange`,Ye),u.onteardown=async()=>{if(d.signal.aborted)return{};d.abort(),w=void 0,document.removeEventListener?.(`visibilitychange`,Ye);let e=he?.dispose;return he=void 0,Pe(e),k(),{}},u.connect().then(()=>{d.signal.aborted||(te=!0,document.documentElement.dataset.theme=u.getHostContext()?.theme??`light`,Je())}).catch(()=>{d.signal.aborted||(ae=`Could not connect this card to the app.`,k())})}function Q(e){var t=e.width,n=e.height;if(t<0)throw Error(`Negative width is not allowed for Size`);if(n<0)throw Error(`Negative height is not allowed for Size`);return{width:t,height:n}}function lS(e,t){return e.width===t.width&&e.height===t.height}var uS=function(){function e(e){var t=this;this._resolutionListener=function(){return t._onResolutionChanged()},this._resolutionMediaQueryList=null,this._observers=[],this._window=e,this._installResolutionListener()}return e.prototype.dispose=function(){this._uninstallResolutionListener(),this._window=null},Object.defineProperty(e.prototype,"value",{get:function(){return this._window.devicePixelRatio},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=this,n={next:e};return this._observers.push(n),{unsubscribe:function(){t._observers=t._observers.filter(function(e){return e!==n})}}},e.prototype._installResolutionListener=function(){if(this._resolutionMediaQueryList!==null)throw Error(`Resolution listener is already installed`);var e=this._window.devicePixelRatio;this._resolutionMediaQueryList=this._window.matchMedia(`all and (resolution: ${e}dppx)`),this._resolutionMediaQueryList.addListener(this._resolutionListener)},e.prototype._uninstallResolutionListener=function(){this._resolutionMediaQueryList!==null&&(this._resolutionMediaQueryList.removeListener(this._resolutionListener),this._resolutionMediaQueryList=null)},e.prototype._reinstallResolutionListener=function(){this._uninstallResolutionListener(),this._installResolutionListener()},e.prototype._onResolutionChanged=function(){var e=this;this._observers.forEach(function(t){return t.next(e._window.devicePixelRatio)}),this._reinstallResolutionListener()},e}();function dS(e){return new uS(e)}var fS=function(){function e(e,t,n){this._canvasElement=null,this._bitmapSizeChangedListeners=[],this._suggestedBitmapSize=null,this._suggestedBitmapSizeChangedListeners=[],this._devicePixelRatioObservable=null,this._canvasElementResizeObserver=null,this._canvasElement=e,this._canvasElementClientSize=Q({width:this._canvasElement.clientWidth,height:this._canvasElement.clientHeight}),this._transformBitmapSize=t??(function(e){return e}),this._allowResizeObserver=n?.allowResizeObserver??!0,this._chooseAndInitObserver()}return e.prototype.dispose=function(){var e,t;if(this._canvasElement===null)throw Error(`Object is disposed`);(e=this._canvasElementResizeObserver)==null||e.disconnect(),this._canvasElementResizeObserver=null,(t=this._devicePixelRatioObservable)==null||t.dispose(),this._devicePixelRatioObservable=null,this._suggestedBitmapSizeChangedListeners.length=0,this._bitmapSizeChangedListeners.length=0,this._canvasElement=null},Object.defineProperty(e.prototype,"canvasElement",{get:function(){if(this._canvasElement===null)throw Error(`Object is disposed`);return this._canvasElement},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canvasElementClientSize",{get:function(){return this._canvasElementClientSize},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bitmapSize",{get:function(){return Q({width:this.canvasElement.width,height:this.canvasElement.height})},enumerable:!1,configurable:!0}),e.prototype.resizeCanvasElement=function(e){this._canvasElementClientSize=Q(e),this.canvasElement.style.width=`${this._canvasElementClientSize.width}px`,this.canvasElement.style.height=`${this._canvasElementClientSize.height}px`,this._invalidateBitmapSize()},e.prototype.subscribeBitmapSizeChanged=function(e){this._bitmapSizeChangedListeners.push(e)},e.prototype.unsubscribeBitmapSizeChanged=function(e){this._bitmapSizeChangedListeners=this._bitmapSizeChangedListeners.filter(function(t){return t!==e})},Object.defineProperty(e.prototype,"suggestedBitmapSize",{get:function(){return this._suggestedBitmapSize},enumerable:!1,configurable:!0}),e.prototype.subscribeSuggestedBitmapSizeChanged=function(e){this._suggestedBitmapSizeChangedListeners.push(e)},e.prototype.unsubscribeSuggestedBitmapSizeChanged=function(e){this._suggestedBitmapSizeChangedListeners=this._suggestedBitmapSizeChangedListeners.filter(function(t){return t!==e})},e.prototype.applySuggestedBitmapSize=function(){if(this._suggestedBitmapSize!==null){var e=this._suggestedBitmapSize;this._suggestedBitmapSize=null,this._resizeBitmap(e),this._emitSuggestedBitmapSizeChanged(e,this._suggestedBitmapSize)}},e.prototype._resizeBitmap=function(e){var t=this.bitmapSize;lS(t,e)||(this.canvasElement.width=e.width,this.canvasElement.height=e.height,this._emitBitmapSizeChanged(t,e))},e.prototype._emitBitmapSizeChanged=function(e,t){var n=this;this._bitmapSizeChangedListeners.forEach(function(r){return r.call(n,e,t)})},e.prototype._suggestNewBitmapSize=function(e){var t=this._suggestedBitmapSize,n=Q(this._transformBitmapSize(e,this._canvasElementClientSize)),r=lS(this.bitmapSize,n)?null:n;(t!==null||r!==null)&&(t!==null&&r!==null&&lS(t,r)||(this._suggestedBitmapSize=r,this._emitSuggestedBitmapSizeChanged(t,r)))},e.prototype._emitSuggestedBitmapSizeChanged=function(e,t){var n=this;this._suggestedBitmapSizeChangedListeners.forEach(function(r){return r.call(n,e,t)})},e.prototype._chooseAndInitObserver=function(){var e=this;this._allowResizeObserver?hS().then(function(t){return t?e._initResizeObserver():e._initDevicePixelRatioObservable()}):this._initDevicePixelRatioObservable()},e.prototype._initDevicePixelRatioObservable=function(){var e=this;if(this._canvasElement!==null){var t=mS(this._canvasElement);if(t===null)throw Error(`No window is associated with the canvas`);this._devicePixelRatioObservable=dS(t),this._devicePixelRatioObservable.subscribe(function(){return e._invalidateBitmapSize()}),this._invalidateBitmapSize()}},e.prototype._invalidateBitmapSize=function(){if(this._canvasElement!==null){var e=mS(this._canvasElement);if(e!==null){var t=this._devicePixelRatioObservable?.value??e.devicePixelRatio,n=this._canvasElement.getClientRects(),r=n[0]===void 0?Q({width:this._canvasElementClientSize.width*t,height:this._canvasElementClientSize.height*t}):gS(n[0],t);this._suggestNewBitmapSize(r)}}},e.prototype._initResizeObserver=function(){var e=this;this._canvasElement!==null&&(this._canvasElementResizeObserver=new ResizeObserver(function(t){var n=t.find(function(t){return t.target===e._canvasElement});if(n&&n.devicePixelContentBoxSize&&n.devicePixelContentBoxSize[0]){var r=n.devicePixelContentBoxSize[0],i=Q({width:r.inlineSize,height:r.blockSize});e._suggestNewBitmapSize(i)}}),this._canvasElementResizeObserver.observe(this._canvasElement,{box:`device-pixel-content-box`}))},e}();function pS(e,t){if(t.type===`device-pixel-content-box`)return new fS(e,t.transform,t.options);throw Error(`Unsupported binding target`)}function mS(e){return e.ownerDocument.defaultView}function hS(){return new Promise(function(e){var t=new ResizeObserver(function(n){e(n.every(function(e){return`devicePixelContentBoxSize`in e})),t.disconnect()});t.observe(document.body,{box:`device-pixel-content-box`})}).catch(function(){return!1})}function gS(e,t){return Q({width:Math.round(e.left*t+e.width*t)-Math.round(e.left*t),height:Math.round(e.top*t+e.height*t)-Math.round(e.top*t)})}var _S=function(){function e(e,t,n){if(t.width===0||t.height===0)throw TypeError(`Rendering target could only be created on a media with positive width and height`);if(this._mediaSize=t,n.width===0||n.height===0)throw TypeError(`Rendering target could only be created using a bitmap with positive integer width and height`);this._bitmapSize=n,this._context=e}return e.prototype.useMediaCoordinateSpace=function(e){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),this._context.scale(this._horizontalPixelRatio,this._verticalPixelRatio),e({context:this._context,mediaSize:this._mediaSize})}finally{this._context.restore()}},e.prototype.useBitmapCoordinateSpace=function(e){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),e({context:this._context,mediaSize:this._mediaSize,bitmapSize:this._bitmapSize,horizontalPixelRatio:this._horizontalPixelRatio,verticalPixelRatio:this._verticalPixelRatio})}finally{this._context.restore()}},Object.defineProperty(e.prototype,"_horizontalPixelRatio",{get:function(){return this._bitmapSize.width/this._mediaSize.width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_verticalPixelRatio",{get:function(){return this._bitmapSize.height/this._mediaSize.height},enumerable:!1,configurable:!0}),e}();function vS(e,t){var n=e.canvasElementClientSize;if(n.width===0||n.height===0)return null;var r=e.bitmapSize;if(r.width===0||r.height===0)return null;var i=e.canvasElement.getContext(`2d`,t);return i===null?null:new _S(i,n,r)}var yS={title:``,visible:!0,hitTestTolerance:3,lastValueVisible:!0,priceLineVisible:!0,priceLineSource:0,priceLineWidth:1,priceLineColor:``,priceLineStyle:2,baseLineVisible:!0,baseLineWidth:1,baseLineColor:`#B2B5BE`,baseLineStyle:0,priceFormat:{type:`price`,precision:2,minMove:.01}},bS,xS;function SS(e,t){let n=function(e,t){switch(e){case 0:default:return[];case 1:return[t,t];case 2:return[2*t,2*t];case 3:return[6*t,6*t];case 4:return[t,4*t]}}(t,e.lineWidth);return e.setLineDash(n),n}function CS(e,t,n,r){e.beginPath();let i=e.lineWidth%2?.5:0;e.moveTo(n,t+i),e.lineTo(r,t+i),e.stroke()}function wS(e,t){if(!e)throw Error(`Assertion failed`+(t?`: `+t:``))}function TS(e){if(e===void 0)throw Error(`Value is undefined`);return e}function $(e){if(e===null)throw Error(`Value is null`);return e}function ES(e){return $(TS(e))}(function(e){e[e.Simple=0]=`Simple`,e[e.WithSteps=1]=`WithSteps`,e[e.Curved=2]=`Curved`})(bS||={}),function(e){e[e.Solid=0]=`Solid`,e[e.Dotted=1]=`Dotted`,e[e.Dashed=2]=`Dashed`,e[e.LargeDashed=3]=`LargeDashed`,e[e.SparseDotted=4]=`SparseDotted`}(xS||={});var DS=class{constructor(){this.t=[]}i(e,t,n){let r={h:e,l:t,o:!0===n};this.t.push(r)}_(e){let t=this.t.findIndex((t=>e===t.h));t>-1&&this.t.splice(t,1)}u(e){this.t=this.t.filter((t=>t.l!==e))}p(e,t,n){let r=[...this.t];this.t=this.t.filter((e=>!e.o)),r.forEach((r=>r.h(e,t,n)))}v(){return this.t.length>0}m(){this.t=[]}};function OS(e,...t){for(let n of t)for(let t in n)n[t]!==void 0&&Object.prototype.hasOwnProperty.call(n,t)&&![`__proto__`,`constructor`,`prototype`].includes(t)&&(typeof n[t]!=`object`||e[t]===void 0||Array.isArray(n[t])?e[t]=n[t]:OS(e[t],n[t]));return e}function kS(e){return typeof e==`number`&&isFinite(e)}function AS(e){return typeof e==`number`&&e%1==0}function jS(e){return typeof e==`string`}function MS(e){return typeof e==`boolean`}function NS(e){let t=e;if(!t||typeof t!=`object`)return t;let n,r,i;for(r in n=Array.isArray(t)?[]:{},t)t.hasOwnProperty(r)&&(i=t[r],n[r]=i&&typeof i==`object`?NS(i):i);return n}function PS(e){return e!==null}function FS(e){return e===null?void 0:e}var IS=`-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif`;function LS(e,t,n){return t===void 0&&(t=IS),`${n=n===void 0?``:`${n} `}${e}px ${t}`}var RS=class{constructor(e){this.M={S:1,C:5,P:NaN,k:``,T:``,R:``,D:``,I:0,V:0,B:0,A:0,L:0},this.O=e}N(){let e=this.M,t=this.F(),n=this.W();return e.P===t&&e.T===n||(e.P=t,e.T=n,e.k=LS(t,n),e.A=2.5/12*t,e.I=e.A,e.V=t/12*e.C,e.B=t/12*e.C,e.L=0),e.R=this.H(),e.D=this.U(),this.M}H(){return this.O.N().layout.textColor}U(){return this.O.$()}F(){return this.O.N().layout.fontSize}W(){return this.O.N().layout.fontFamily}};function zS(e){return e<0?0:e>255?255:Math.round(e)||0}function BS(e){return .199*e[0]+.687*e[1]+.114*e[2]}var VS=class{constructor(e,t){this.j=new Map,this.q=e,t&&(this.j=t)}Y(e,t){if(e===`transparent`)return e;let n=this.K(e),r=n[3];return`rgba(${n[0]}, ${n[1]}, ${n[2]}, ${t*r})`}G(e){let t=this.K(e);return{Z:`rgb(${t[0]}, ${t[1]}, ${t[2]})`,X:BS(t)>160?`black`:`white`}}J(e){return BS(this.K(e))}tt(e,t,n){let[r,i,a,o]=this.K(e),[s,c,l,u]=this.K(t),d=[zS(r+n*(s-r)),zS(i+n*(c-i)),zS(a+n*(l-a)),(f=o+n*(u-o),f<=0||f>1?Math.min(Math.max(f,0),1):Math.round(1e4*f)/1e4)];var f;return`rgba(${d[0]}, ${d[1]}, ${d[2]}, ${d[3]})`}K(e){let t=this.j.get(e);if(t)return t;let n=function(e){let t=document.createElement(`div`);t.style.display=`none`,document.body.appendChild(t),t.style.color=e;let n=window.getComputedStyle(t).color;return document.body.removeChild(t),n}(e).match(/^rgba?\s*\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d+))?\)$/);if(!n){if(this.q.length)for(let t of this.q){let n=t(e);if(n)return this.j.set(e,n),n}throw Error(`Failed to parse color: ${e}`)}let r=[parseInt(n[1],10),parseInt(n[2],10),parseInt(n[3],10),n[4]?parseFloat(n[4]):1];return this.j.set(e,r),r}},HS=class{constructor(){this.it=[]}nt(e){this.it=e}st(e,t,n){this.it.forEach((r=>{r.st(e,t,n)}))}},US=class{st(e,t,n){e.useBitmapCoordinateSpace((e=>this.et(e,t,n)))}},WS=class extends US{constructor(){super(...arguments),this.rt=null}ht(e){this.rt=e}et({context:e,horizontalPixelRatio:t,verticalPixelRatio:n}){if(this.rt===null||this.rt.lt===null)return;let r=this.rt.lt,i=this.rt,a=Math.max(1,Math.floor(t))%2/2,o=o=>{e.beginPath();for(let s=r.to-1;s>=r.from;--s){let r=i.ot[s],c=Math.round(r._t*t)+a,l=r.ut*n,u=o*n+a;e.moveTo(c,l),e.arc(c,l,u,0,2*Math.PI)}e.fill()};i.ct>0&&(e.fillStyle=i.dt,o(i.ft+i.ct)),e.fillStyle=i.vt,o(i.ft)}};function GS(){return{ot:[{_t:0,ut:0,wt:0,Mt:0}],vt:``,dt:``,ft:0,ct:0,lt:null}}var KS={from:0,to:1},qS=class{constructor(e,t,n){this.gt=new HS,this.bt=[],this.St=[],this.xt=!0,this.O=e,this.Ct=t,this.yt=n,this.gt.nt(this.bt)}Pt(e){this.kt(),this.xt=!0}Tt(){return this.xt&&=(this.Rt(),!1),this.gt}kt(){let e=this.yt.Dt();e.length!==this.bt.length&&(this.St=e.map(GS),this.bt=this.St.map((e=>{let t=new WS;return t.ht(e),t})),this.gt.nt(this.bt))}Rt(){let e=this.Ct.N().mode===2||!this.Ct.It(),t=this.yt.Vt(),n=this.Ct.Bt(),r=this.O.Et();this.kt(),t.forEach(((t,i)=>{let a=this.St[i],o=t.At(n),s=t.Lt();!e&&o!==null&&t.It()&&s!==null?(a.vt=o.zt,a.ft=o.ft,a.ct=o.Ot,a.ot[0].Mt=o.Mt,a.ot[0].ut=t.Ft().Nt(o.Mt,s.Wt),a.dt=o.Ht??this.O.Ut(a.ot[0].ut/t.Ft().$t()),a.ot[0].wt=n,a.ot[0]._t=r.jt(n),a.lt=KS):a.lt=null}))}},JS=class extends US{constructor(e){super(),this.qt=e}et({context:e,bitmapSize:t,horizontalPixelRatio:n,verticalPixelRatio:r}){if(this.qt===null)return;let i=this.qt.Yt.It,a=this.qt.Kt.It;if(!i&&!a)return;let o=Math.round(this.qt._t*n),s=Math.round(this.qt.ut*r);e.lineCap=`butt`,i&&o>=0&&(e.lineWidth=Math.floor(this.qt.Yt.ct*n),e.strokeStyle=this.qt.Yt.R,e.fillStyle=this.qt.Yt.R,SS(e,this.qt.Yt.Gt),function(e,t,n,r){e.beginPath();let i=e.lineWidth%2?.5:0;e.moveTo(t+i,n),e.lineTo(t+i,r),e.stroke()}(e,o,0,t.height)),a&&s>=0&&(e.lineWidth=Math.floor(this.qt.Kt.ct*r),e.strokeStyle=this.qt.Kt.R,e.fillStyle=this.qt.Kt.R,SS(e,this.qt.Kt.Gt),CS(e,s,0,t.width))}},YS=class{constructor(e,t){this.xt=!0,this.Zt={Yt:{ct:1,Gt:0,R:``,It:!1},Kt:{ct:1,Gt:0,R:``,It:!1},_t:0,ut:0},this.Xt=new JS(this.Zt),this.Jt=e,this.yt=t}Pt(){this.xt=!0}Tt(e){return this.xt&&=(this.Rt(),!1),this.Xt}Rt(){let e=this.Jt.It(),t=this.yt.Qt().N().crosshair,n=this.Zt;if(t.mode===2)return n.Kt.It=!1,void(n.Yt.It=!1);n.Kt.It=e&&this.Jt.ti(this.yt),n.Yt.It=e&&this.Jt.ii(),n.Kt.ct=t.horzLine.width,n.Kt.Gt=t.horzLine.style,n.Kt.R=t.horzLine.color,n.Yt.ct=t.vertLine.width,n.Yt.Gt=t.vertLine.style,n.Yt.R=t.vertLine.color,n._t=this.Jt.ni(),n.ut=this.Jt.si()}};function XS(e,t,n,r,i,a){e.fillRect(t+a,n,r-2*a,a),e.fillRect(t+a,n+i-a,r-2*a,a),e.fillRect(t,n,a,i),e.fillRect(t+r-a,n,a,i)}function ZS(e,t,n,r,i,a){e.save(),e.globalCompositeOperation=`copy`,e.fillStyle=a,e.fillRect(t,n,r,i),e.restore()}function QS(e,t,n,r,i,a){e.beginPath(),e.roundRect?e.roundRect(t,n,r,i,a):(e.lineTo(t+r-a[1],n),a[1]!==0&&e.arcTo(t+r,n,t+r,n+a[1],a[1]),e.lineTo(t+r,n+i-a[2]),a[2]!==0&&e.arcTo(t+r,n+i,t+r-a[2],n+i,a[2]),e.lineTo(t+a[3],n+i),a[3]!==0&&e.arcTo(t,n+i,t,n+i-a[3],a[3]),e.lineTo(t,n+a[0]),a[0]!==0&&e.arcTo(t,n,t+a[0],n,a[0]))}function $S(e,t,n,r,i,a,o=0,s=[0,0,0,0],c=``){if(e.save(),!o||!c||c===a)return QS(e,t,n,r,i,s),e.fillStyle=a,e.fill(),void e.restore();let l=o/2;var u;QS(e,t+l,n+l,r-o,i-o,(u=-l,s.map((e=>e===0?e:e+u)))),a!==`transparent`&&(e.fillStyle=a,e.fill()),c!==`transparent`&&(e.lineWidth=o,e.strokeStyle=c,e.closePath(),e.stroke()),e.restore()}function eC(e,t,n,r,i,a,o){e.save(),e.globalCompositeOperation=`copy`;let s=e.createLinearGradient(0,0,0,i);s.addColorStop(0,a),s.addColorStop(1,o),e.fillStyle=s,e.fillRect(t,n,r,i),e.restore()}var tC=class{constructor(e,t){this.ht(e,t)}ht(e,t){this.qt=e,this.ei=t}$t(e,t){return this.qt.It?e.P+e.A+e.I:0}st(e,t,n,r){if(!this.qt.It||this.qt.ri.length===0)return;let i=this.qt.R,a=this.ei.Z,o=e.useBitmapCoordinateSpace((e=>{let o=e.context;o.font=t.k;let s=this.hi(e,t,n,r),c=s.ai;return s.li?$S(o,c.oi,c._i,c.ui,c.ci,a,c.di,[c.ft,0,0,c.ft],a):$S(o,c.fi,c._i,c.ui,c.ci,a,c.di,[0,c.ft,c.ft,0],a),this.qt.pi&&(o.fillStyle=i,o.fillRect(c.fi,c.mi,c.wi-c.fi,c.Mi)),this.qt.gi&&(o.fillStyle=t.D,o.fillRect(s.li?c.bi-c.di:0,c._i,c.di,c.Si-c._i)),s}));e.useMediaCoordinateSpace((({context:e})=>{let n=o.xi;e.font=t.k,e.textAlign=o.li?`right`:`left`,e.textBaseline=`middle`,e.fillStyle=i,e.fillText(this.qt.ri,n.Ci,(n._i+n.Si)/2+n.yi)}))}hi(e,t,n,r){let{context:i,bitmapSize:a,mediaSize:o,horizontalPixelRatio:s,verticalPixelRatio:c}=e,l=this.qt.pi||!this.qt.Pi?t.C:0,u=this.qt.ki?t.S:0,d=t.A+this.ei.Ti,f=t.I+this.ei.Ri,p=t.V,m=t.B,h=this.qt.ri,g=t.P,_=n.Di(i,h),v=Math.ceil(n.Ii(i,h)),y=g+d+f,b=t.S+p+m+v+l,ee=Math.max(1,Math.floor(c)),x=Math.round(y*c);x%2!=ee%2&&(x+=1);let te=u>0?Math.max(1,Math.floor(u*s)):0,ne=Math.round(b*s),re=Math.round(l*s),ie=this.ei.Vi??this.ei.Bi??this.ei.Ei,S=Math.round(ie*c)-Math.floor(.5*c),ae=Math.floor(S+ee/2-x/2),oe=ae+x,se=r===`right`,C=se?o.width-u:u,w=se?a.width-te:te,T,E,ce;return se?(T=w-ne,E=w-re,ce=C-l-p-u):(T=w+ne,E=w+re,ce=C+l+p),{li:se,ai:{_i:ae,mi:S,Si:oe,ui:ne,ci:x,ft:2*s,di:te,oi:T,fi:w,wi:E,Mi:ee,bi:a.width},xi:{_i:ae/c,Si:oe/c,Ci:ce,yi:_}}}},nC=class{constructor(e){this.Ai={Ei:0,Z:`#000`,Ri:0,Ti:0},this.Li={ri:``,It:!1,pi:!0,Pi:!1,Ht:``,R:`#FFF`,gi:!1,ki:!1},this.zi={ri:``,It:!1,pi:!1,Pi:!0,Ht:``,R:`#FFF`,gi:!0,ki:!0},this.xt=!0,this.Oi=new(e||tC)(this.Li,this.Ai),this.Ni=new(e||tC)(this.zi,this.Ai)}ri(){return this.Fi(),this.Li.ri}Ei(){return this.Fi(),this.Ai.Ei}Pt(){this.xt=!0}$t(e,t=!1){return Math.max(this.Oi.$t(e,t),this.Ni.$t(e,t))}Wi(){return this.Ai.Vi??null}Hi(){return this.Ai.Vi??this.Ai.Bi??this.Ei()}Ui(e){this.Ai.Bi=e??void 0}$i(){return this.Fi(),this.Li.It||this.zi.It}ji(){return this.Fi(),this.Li.It}Tt(e){return this.Fi(),this.Li.pi=this.Li.pi&&e.N().ticksVisible,this.zi.pi=this.zi.pi&&e.N().ticksVisible,this.Oi.ht(this.Li,this.Ai),this.Ni.ht(this.zi,this.Ai),this.Oi}qi(){return this.Fi(),this.Oi.ht(this.Li,this.Ai),this.Ni.ht(this.zi,this.Ai),this.Ni}Fi(){this.xt&&(this.Li.pi=!0,this.zi.pi=!1,this.Yi(this.Li,this.zi,this.Ai))}},rC=class extends nC{constructor(e,t,n){super(),this.Jt=e,this.Ki=t,this.Gi=n}Yi(e,t,n){if(e.It=!1,this.Jt.N().mode===2)return;let r=this.Jt.N().horzLine;if(!r.labelVisible)return;let i=this.Ki.Lt();if(!this.Jt.It()||this.Ki.Zi()||i===null)return;let a=this.Ki.Xi().G(r.labelBackgroundColor);n.Z=a.Z,e.R=a.X;let o=2/12*this.Ki.P();n.Ti=o,n.Ri=o;let s=this.Gi(this.Ki);n.Ei=s.Ei,e.ri=this.Ki.Ji(s.Mt,i),e.It=!0}},iC=/[1-9]/g,aC=class{constructor(){this.qt=null}ht(e){this.qt=e}st(e,t){if(this.qt===null||!1===this.qt.It||this.qt.ri.length===0)return;let n=e.useMediaCoordinateSpace((({context:e})=>(e.font=t.k,Math.round(t.Qi.Ii(e,$(this.qt).ri,iC)))));if(n<=0)return;let r=t.tn,i=n+2*r,a=i/2,o=this.qt.nn,s=this.qt.Ei,c=Math.floor(s-a)+.5;c<0?(s+=Math.abs(0-c),c=Math.floor(s-a)+.5):c+i>o&&(s-=Math.abs(o-(c+i)),c=Math.floor(s-a)+.5);let l=c+i,u=Math.ceil(0+t.S+t.C+t.A+t.P+t.I);e.useBitmapCoordinateSpace((({context:e,horizontalPixelRatio:n,verticalPixelRatio:r})=>{let i=$(this.qt);e.fillStyle=i.Z;let a=Math.round(c*n),o=Math.round(0*r),s=Math.round(l*n),d=Math.round(u*r),f=Math.round(2*n);if(e.beginPath(),e.moveTo(a,o),e.lineTo(a,d-f),e.arcTo(a,d,a+f,d,f),e.lineTo(s-f,d),e.arcTo(s,d,s,d-f,f),e.lineTo(s,o),e.fill(),i.pi){let a=Math.round(i.Ei*n),s=o,c=Math.round((s+t.C)*r);e.fillStyle=i.R;let l=Math.max(1,Math.floor(n)),u=Math.floor(.5*n);e.fillRect(a-u,s,l,c-s)}})),e.useMediaCoordinateSpace((({context:e})=>{let n=$(this.qt),i=0+t.S+t.C+t.A+t.P/2;e.font=t.k,e.textAlign=`left`,e.textBaseline=`middle`,e.fillStyle=n.R;let a=t.Qi.Di(e,`Apr0`);e.translate(c+r,i+a),e.fillText(n.ri,0,0)}))}},oC=class{constructor(e,t,n){this.xt=!0,this.Xt=new aC,this.Zt={It:!1,Z:`#4c525e`,R:`white`,ri:``,nn:0,Ei:NaN,pi:!0},this.Ct=e,this.sn=t,this.Gi=n}Pt(){this.xt=!0}Tt(){return this.xt&&=(this.Rt(),!1),this.Xt.ht(this.Zt),this.Xt}Rt(){let e=this.Zt;if(e.It=!1,this.Ct.N().mode===2)return;let t=this.Ct.N().vertLine;if(!t.labelVisible)return;let n=this.sn.Et();if(n.Zi())return;e.nn=n.nn();let r=this.Gi();if(r===null)return;e.Ei=r.Ei;let i=n.en(this.Ct.Bt());e.ri=n.rn($(i)),e.It=!0;let a=this.sn.Xi().G(t.labelBackgroundColor);e.Z=a.Z,e.R=a.X,e.pi=n.N().ticksVisible}},sC=class{constructor(){this.hn=null,this.an=0}ln(){return this.an}_n(e){this.an=e}Ft(){return this.hn}un(e){this.hn=e}cn(e){return[]}dn(){return[]}It(){return!0}},cC;(function(e){e[e.Normal=0]=`Normal`,e[e.Magnet=1]=`Magnet`,e[e.Hidden=2]=`Hidden`,e[e.MagnetOHLC=3]=`MagnetOHLC`})(cC||={});var lC=class extends sC{constructor(e,t){super(),this.yt=null,this.fn=NaN,this.pn=0,this.vn=!1,this.mn=new Map,this.wn=!1,this.Mn=new WeakMap,this.gn=new WeakMap,this.bn=NaN,this.Sn=NaN,this.xn=NaN,this.Cn=NaN,this.sn=e,this.yn=t,this.Pn=((e,t)=>n=>{let r=t(),i=e();if(n===$(this.yt).kn())return{Mt:i,Ei:r};{let e=$(n.Lt());return{Mt:n.Tn(r,e),Ei:r}}})((()=>this.fn),(()=>this.Sn));let n=((e,t)=>()=>{let n=this.sn.Et().Rn(e()),r=t();return n&&Number.isFinite(r)?{wt:n,Ei:r}:null})((()=>this.pn),(()=>this.ni()));this.Dn=new oC(this,e,n)}N(){return this.yn}In(e,t){this.xn=e,this.Cn=t}Vn(){this.xn=NaN,this.Cn=NaN}Bn(){return this.xn}En(){return this.Cn}An(e,t,n){this.wn||=!0,this.vn=!0,this.Ln(e,t,n)}Bt(){return this.pn}ni(){return this.bn}si(){return this.Sn}It(){return this.vn}zn(){this.vn=!1,this.On(),this.fn=NaN,this.bn=NaN,this.Sn=NaN,this.yt=null,this.Vn(),this.Nn()}Fn(e){if(!this.yn.doNotSnapToHiddenSeriesIndices)return e;let t=this.sn,n=t.Et(),r=null,i=null;for(let n of t.Wn()){let t=n.Un().Hn(e,-1);if(t){if(t.$n===e)return e;(r===null||t.$n>r)&&(r=t.$n)}let a=n.Un().Hn(e,1);if(a){if(a.$n===e)return e;(i===null||a.$n<i)&&(i=a.$n)}}let a=[r,i].filter(PS);if(a.length===0)return e;let o=n.jt(e),s=a.map((e=>Math.abs(o-n.jt(e))));return a[s.indexOf(Math.min(...s))]}jn(e){let t=this.Mn.get(e);t||(t=new YS(this,e),this.Mn.set(e,t));let n=this.gn.get(e);return n||(n=new qS(this.sn,this,e),this.gn.set(e,n)),[t,n]}ti(e){return e===this.yt&&this.yn.horzLine.visible}ii(){return this.yn.vertLine.visible}qn(e,t){this.vn&&this.yt===e||this.mn.clear();let n=[];return this.yt===e&&n.push(this.Yn(this.mn,t,this.Pn)),n}dn(){return this.vn?[this.Dn]:[]}Kn(){return this.yt}Nn(){this.sn.Gn().forEach((e=>{this.Mn.get(e)?.Pt(),this.gn.get(e)?.Pt()})),this.mn.forEach((e=>e.Pt())),this.Dn.Pt()}Zn(e){return e&&!e.kn().Zi()?e.kn():null}Ln(e,t,n){this.Xn(e,t,n)&&this.Nn()}Xn(e,t,n){let r=this.bn,i=this.Sn,a=this.fn,o=this.pn,s=this.yt,c=this.Zn(n);this.pn=e,this.bn=isNaN(e)?NaN:this.sn.Et().jt(e),this.yt=n;let l=c===null?null:c.Lt();return c!==null&&l!==null?(this.fn=t,this.Sn=c.Nt(t,l)):(this.fn=NaN,this.Sn=NaN),r!==this.bn||i!==this.Sn||o!==this.pn||a!==this.fn||s!==this.yt}On(){let e=this.sn.Jn().map((e=>e.Un().Qn())).filter(PS),t=e.length===0?null:Math.max(...e);this.pn=t===null?NaN:t}Yn(e,t,n){let r=e.get(t);return r===void 0&&(r=new rC(this,t,n),e.set(t,r)),r}};function uC(e){return e===`left`||e===`right`}var dC=class e{constructor(e){this.ts=new Map,this.ns=[],this.ss=e}es(e,t){let n=function(e,t){return e===void 0?t:{rs:Math.max(e.rs,t.rs),hs:e.hs||t.hs}}(this.ts.get(e),t);this.ts.set(e,n)}ls(){return this.ss}_s(e){let t=this.ts.get(e);return t===void 0?{rs:this.ss}:{rs:Math.max(this.ss,t.rs),hs:t.hs}}us(){this.cs(),this.ns=[{ds:0}]}fs(e){this.cs(),this.ns=[{ds:1,Wt:e}]}ps(e){this.vs(),this.ns.push({ds:5,Wt:e})}cs(){this.vs(),this.ns.push({ds:6})}ws(){this.cs(),this.ns=[{ds:4}]}Ms(e){this.cs(),this.ns.push({ds:2,Wt:e})}gs(e){this.cs(),this.ns.push({ds:3,Wt:e})}bs(){return this.ns}Ss(e){for(let t of e.ns)this.xs(t);this.ss=Math.max(this.ss,e.ss),e.ts.forEach(((e,t)=>{this.es(t,e)}))}static Cs(){return new e(2)}static ys(){return new e(3)}xs(e){switch(e.ds){case 0:this.us();break;case 1:this.fs(e.Wt);break;case 2:this.Ms(e.Wt);break;case 3:this.gs(e.Wt);break;case 4:this.ws();break;case 5:this.ps(e.Wt);break;case 6:this.vs()}}vs(){let e=this.ns.findIndex((e=>e.ds===5));e!==-1&&this.ns.splice(e,1)}},fC=class{formatTickmarks(e){return e.map((e=>this.format(e)))}},pC=`.`;function mC(e,t){if(!kS(e))return`n/a`;if(!AS(t)||t<0||t>16)throw TypeError(`invalid length`);return t===0?e.toString():(`0000000000000000`+e.toString()).slice(-t)}var hC=class extends fC{constructor(e,t){if(super(),t||=1,kS(e)&&AS(e)||(e=100),e<0)throw TypeError(`invalid base`);this.Ki=e,this.Ps=t,this.ks()}format(e){let t=e<0?`−`:``;return e=Math.abs(e),t+this.Ts(e)}ks(){if(this.Rs=0,this.Ki>0&&this.Ps>0){let e=this.Ki;for(;e>1;)e/=10,this.Rs++}}Ts(e){let t=this.Ki/this.Ps,n=Math.floor(e),r=``,i=this.Rs===void 0?NaN:this.Rs;if(t>1){let a=+(Math.round(e*t)-n*t).toFixed(this.Rs);a>=t&&(a-=t,n+=1),r=pC+mC(+a.toFixed(this.Rs)*this.Ps,i)}else n=Math.round(n*t)/t,i>0&&(r=pC+mC(0,i));return n.toFixed(0)+r}},gC=class extends hC{constructor(e=100){super(e)}format(e){return`${super.format(e)}%`}},_C=class extends fC{constructor(e){super(),this.Ds=e}format(e){let t=``;return e<0&&(t=`-`,e=-e),e<995?t+this.Is(e):e<999995?t+this.Is(e/1e3)+`K`:e<999999995?(e=1e3*Math.round(e/1e3),t+this.Is(e/1e6)+`M`):(e=1e6*Math.round(e/1e6),t+this.Is(e/1e9)+`B`)}Is(e){let t,n=10**this.Ds;return t=(e=Math.round(e*n)/n)>=1e-15&&e<1?e.toFixed(this.Ds).replace(/\.?0+$/,``):String(e),t.replace(/(\.[1-9]*)0+$/,((e,t)=>t))}},vC=/[2-9]/g,yC=class{constructor(e=50){this.Vs=0,this.Bs=1,this.Es=1,this.As={},this.Ls=new Map,this.zs=e}Os(){this.Vs=0,this.Ls.clear(),this.Bs=1,this.Es=1,this.As={}}Ii(e,t,n){return this.Ns(e,t,n).width}Di(e,t,n){let r=this.Ns(e,t,n);return((r.actualBoundingBoxAscent||0)-(r.actualBoundingBoxDescent||0))/2}Ns(e,t,n){let r=n||vC,i=String(t).replace(r,`0`);if(this.Ls.has(i))return TS(this.Ls.get(i)).Fs;if(this.Vs===this.zs){let e=this.As[this.Es];delete this.As[this.Es],this.Ls.delete(e),this.Es++,this.Vs--}e.save(),e.textBaseline=`middle`;let a=e.measureText(i);return e.restore(),a.width===0&&t.length||(this.Ls.set(i,{Fs:a,Ws:this.Bs}),this.As[this.Bs]=i,this.Vs++,this.Bs++),a}},bC=class{constructor(e){this.Hs=null,this.M=null,this.Us=`right`,this.$s=e}js(e,t,n){this.Hs=e,this.M=t,this.Us=n}st(e){this.M!==null&&this.Hs!==null&&this.Hs.st(e,this.M,this.$s,this.Us)}},xC=class{constructor(e,t,n){this.qs=e,this.$s=new yC(50),this.Ys=t,this.O=n,this.F=-1,this.Xt=new bC(this.$s)}Tt(){let e=this.O.Ks(this.Ys);if(e===null)return null;let t=e.Gs(this.Ys)?e.Zs():this.Ys.Ft();if(t===null)return null;let n=e.Xs(t);if(n===`overlay`)return null;let r=this.O.Js();return r.P!==this.F&&(this.F=r.P,this.$s.Os()),this.Xt.js(this.qs.qi(),r,n),this.Xt}},SC=class extends US{constructor(){super(...arguments),this.qt=null}ht(e){this.qt=e}Qs(e,t){if(!this.qt?.It)return null;let{ut:n,ct:r,te:i}=this.qt;return t>=n-r-7&&t<=n+r+7?{ie:this.qt,ne:Math.abs(t-n),se:2,ee:`price-line`,te:i}:null}et({context:e,bitmapSize:t,horizontalPixelRatio:n,verticalPixelRatio:r}){if(this.qt===null||!1===this.qt.It)return;let i=Math.round(this.qt.ut*r);i<0||i>t.height||(e.lineCap=`butt`,e.strokeStyle=this.qt.R,e.lineWidth=Math.floor(this.qt.ct*n),SS(e,this.qt.Gt),CS(e,i,0,t.width))}},CC=class{constructor(e){this.re={ut:0,R:`rgba(0, 0, 0, 0)`,ct:1,Gt:0,It:!1},this.he=new SC,this.xt=!0,this.ae=e,this.le=e.Qt(),this.he.ht(this.re)}Pt(){this.xt=!0}Tt(){return this.ae.It()?(this.xt&&=(this.oe(),!1),this.he):null}},wC=class extends CC{constructor(e){super(e)}oe(){this.re.It=!1;let e=this.ae.Ft(),t=e._e()._e;if(t!==2&&t!==3)return;let n=this.ae.N();if(!n.baseLineVisible||!this.ae.It())return;let r=this.ae.Lt();r!==null&&(this.re.It=!0,this.re.ut=e.Nt(r.Wt,r.Wt),this.re.R=n.baseLineColor,this.re.ct=n.baseLineWidth,this.re.Gt=n.baseLineStyle)}},TC=class extends US{constructor(){super(...arguments),this.qt=null}ht(e){this.qt=e}ue(){return this.qt}et({context:e,horizontalPixelRatio:t,verticalPixelRatio:n}){let r=this.qt;if(r===null)return;let i=Math.max(1,Math.floor(t)),a=i%2/2,o=Math.round(r.ce.x*t)+a,s=r.ce.y*n;e.fillStyle=r.de,e.beginPath();let c=Math.max(2,1.5*r.fe)*t;e.arc(o,s,c,0,2*Math.PI,!1),e.fill(),e.fillStyle=r.pe,e.beginPath(),e.arc(o,s,r.ft*t,0,2*Math.PI,!1),e.fill(),e.lineWidth=i,e.strokeStyle=r.ve,e.beginPath(),e.arc(o,s,r.ft*t+i/2,0,2*Math.PI,!1),e.stroke()}},EC=[{me:0,we:.25,Me:4,ge:10,be:.25,Se:0,xe:.4,Ce:.8},{me:.25,we:.525,Me:10,ge:14,be:0,Se:0,xe:.8,Ce:0},{me:.525,we:1,Me:14,ge:14,be:0,Se:0,xe:0,Ce:0}],DC=class{constructor(e){this.Xt=new TC,this.xt=!0,this.ye=!0,this.Pe=performance.now(),this.ke=this.Pe-1,this.Te=e}Re(){this.ke=this.Pe-1,this.Pt()}De(){if(this.Pt(),this.Te.N().lastPriceAnimation===2){let e=performance.now(),t=this.ke-e;if(t>0)return void(t<650&&(this.ke+=2600));this.Pe=e,this.ke=e+2600}}Pt(){this.xt=!0}Ie(){this.ye=!0}It(){return this.Te.N().lastPriceAnimation!==0}Ve(){switch(this.Te.N().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.ke}}Tt(){return this.xt?(this.Rt(),this.xt=!1,this.ye=!1):this.ye&&=(this.Be(),!1),this.Xt}Rt(){this.Xt.ht(null);let e=this.Te.Qt().Et(),t=e.Ee(),n=this.Te.Lt();if(t===null||n===null)return;let r=this.Te.Ae(!0);if(r.Le||!t.ze(r.$n))return;let i={x:e.jt(r.$n),y:this.Te.Ft().Nt(r.Mt,n.Wt)},a=r.R,o=this.Te.N().lineWidth,s=this.Oe(this.Ne(),a);this.Xt.ht({de:a,fe:o,pe:s.pe,ve:s.ve,ft:s.ft,ce:i})}Be(){let e=this.Xt.ue();if(e!==null){let t=this.Oe(this.Ne(),e.de);e.pe=t.pe,e.ve=t.ve,e.ft=t.ft}}Ne(){return this.Ve()?performance.now()-this.Pe:2599}Fe(e,t,n,r){let i=n+(r-n)*t;return this.Te.Qt().Xi().Y(e,i)}Oe(e,t){let n=e%2600/2600,r;for(let e of EC)if(n>=e.me&&n<=e.we){r=e;break}wS(r!==void 0,`Last price animation internal logic error`);let i=(n-r.me)/(r.we-r.me);return{pe:this.Fe(t,i,r.be,r.Se),ve:this.Fe(t,i,r.xe,r.Ce),ft:(a=i,o=r.Me,s=r.ge,o+(s-o)*a)};var a,o,s}},OC=class extends CC{constructor(e){super(e)}oe(){let e=this.re;e.It=!1;let t=this.ae.N();if(!t.priceLineVisible||!this.ae.It())return;let n=this.ae.Ae(t.priceLineSource===0);n.Le||(e.It=!0,e.ut=n.Ei,e.R=this.ae.We(n.R),e.ct=t.priceLineWidth,e.Gt=t.priceLineStyle)}},kC=class extends nC{constructor(e){super(),this.Jt=e}Yi(e,t,n){e.It=!1,t.It=!1;let r=this.Jt;if(!r.It())return;let i=r.N(),a=i.lastValueVisible,o=r.He()!==``,s=i.seriesLastValueMode===0,c=r.Ae(!1);if(c.Le)return;a&&(e.ri=this.Ue(c,a,s),e.It=e.ri.length!==0),(o||s)&&(t.ri=this.$e(c,a,o,s),t.It=t.ri.length>0);let l=r.We(c.R),u=this.Jt.Qt().Xi().G(l);n.Z=u.Z,n.Ei=c.Ei,t.Ht=r.Qt().Ut(c.Ei/r.Ft().$t()),e.Ht=l,e.R=u.X,t.R=u.X}$e(e,t,n,r){let i=``,a=this.Jt.He();return n&&a.length!==0&&(i+=`${a} `),t&&r&&(i+=this.Jt.Ft().je()?e.qe:e.Ye),i.trim()}Ue(e,t,n){return t?n?this.Jt.Ft().je()?e.Ye:e.qe:e.ri:``}};function AC(e,t,n,r){let i=Number.isFinite(t),a=Number.isFinite(n);return i&&a?e(t,n):i||a?i?t:n:r}var jC=class e{constructor(e,t){this.Ke=e,this.Ge=t}Ze(e){return e!==null&&this.Ke===e.Ke&&this.Ge===e.Ge}Xe(){return new e(this.Ke,this.Ge)}Je(){return this.Ke}Qe(){return this.Ge}tr(){return this.Ge-this.Ke}Zi(){return this.Ge===this.Ke||Number.isNaN(this.Ge)||Number.isNaN(this.Ke)}Ss(t){return t===null?this:new e(AC(Math.min,this.Je(),t.Je(),-1/0),AC(Math.max,this.Qe(),t.Qe(),1/0))}ir(e){if(!kS(e)||this.Ge-this.Ke===0)return;let t=.5*(this.Ge+this.Ke),n=this.Ge-t,r=this.Ke-t;n*=e,r*=e,this.Ge=t+n,this.Ke=t+r}nr(e){kS(e)&&(this.Ge+=e,this.Ke+=e)}sr(){return{minValue:this.Ke,maxValue:this.Ge}}static er(t){return t===null?null:new e(t.minValue,t.maxValue)}},MC=class e{constructor(e,t){this.rr=e,this.hr=t||null}ar(){return this.rr}lr(){return this.hr}sr(){return{priceRange:this.rr===null?null:this.rr.sr(),margins:this.hr||void 0}}static er(t){return t===null?null:new e(jC.er(t.priceRange),t.margins)}},NC=[2,4,8,16,32,64,128,256,512],PC=`Custom series with conflation reducer must have a priceValueBuilder method`,FC=class extends CC{constructor(e,t){super(e),this._r=t}oe(){let e=this.re;e.It=!1;let t=this._r.N();if(!this.ae.It()||!t.lineVisible)return;let n=this._r.ur();n!==null&&(e.It=!0,e.ut=n,e.R=t.color,e.ct=t.lineWidth,e.Gt=t.lineStyle,e.te=this._r.N().id)}},IC=class extends nC{constructor(e,t){super(),this.Te=e,this._r=t}Yi(e,t,n){e.It=!1,t.It=!1;let r=this._r.N(),i=r.axisLabelVisible,a=r.title!==``,o=this.Te;if(!i||!o.It())return;let s=this._r.ur();if(s===null)return;a&&(t.ri=r.title,t.It=!0),t.Ht=o.Qt().Ut(s/o.Ft().$t()),e.ri=this.cr(r.price),e.It=!0;let c=this.Te.Qt().Xi().G(r.axisLabelColor||r.color);n.Z=c.Z;let l=r.axisLabelTextColor||c.X;e.R=l,t.R=l,n.Ei=s}cr(e){let t=this.Te.Lt();return t===null?``:this.Te.Ft().Ji(e,t.Wt)}},LC=class{constructor(e,t){this.Te=e,this.yn=t,this.dr=new FC(e,this),this.qs=new IC(e,this),this.pr=new xC(this.qs,e,e.Qt())}vr(e){OS(this.yn,e),this.Pt(),this.Te.Qt().mr()}N(){return this.yn}wr(){return this.dr}Mr(){return this.pr}gr(){return this.qs}Pt(){this.dr.Pt(),this.qs.Pt()}ur(){let e=this.Te,t=e.Ft();if(e.Qt().Et().Zi()||t.Zi())return null;let n=e.Lt();return n===null?null:t.Nt(this.yn.price,n.Wt)}},RC=class{constructor(){this.br=new WeakMap}Sr(e,t,n){let r=1/t*n;if(e>=r)return 1;let i=r/e;return Math.min(2**Math.floor(Math.log2(i)),512)}Cr(e,t,n,r=!1,i){if(e.length===0||t<=1)return e;let a=this.yr(t);if(a<=1)return e;let o=this.Pr(e),s=o.kr.get(a);return s!==void 0||(s=this.Tr(e,a,n,r,i,o.kr),o.kr.set(a,s)),s}Rr(e,t,n,r,i=!1,a){if(n<1||e.length===0)return e;let o=this.Pr(e),s=o.kr.get(n);if(!s)return this.Cr(e,n,r,i,a);let c=this.Dr(e,t,n,s,i,r,a);return o.kr.set(n,c),c}yr(e){if(e<=2)return 2;for(let t of NC)if(e<=t)return t;return 512}Ir(e){if(e.length===0)return 0;let t=e[0],n=e[e.length-1];return 31*e.length+17*t.$n+13*n.$n}Tr(e,t,n,r=!1,i,a=new Map){if(t===2)return this.Vr(e,2,n,r,i);let o=t/2,s=a.get(o);return s||(s=this.Tr(e,o,n,r,i,a),a.set(o,s)),this.Br(s,n,r,i)}Vr(e,t,n,r=!1,i){let a=this.Er(e,t,n,r,i);return this.Ar(a,r)}Br(e,t,n=!1,r){let i=this.Er(e,2,t,n,r);return this.Ar(i,n)}Er(e,t,n,r=!1,i){let a=[];for(let o=0;o<e.length;o+=t)if(e.length-o>=t){let t=this.Lr(e[o],e[o+1],n,r,i);t.zr=!1,a.push(t)}else if(a.length===0)a.push(this.Or(e[o],!0));else{let t=a[a.length-1];a[a.length-1]=this.Nr(t,e[o],n,r,i)}return a}Fr(e,t){return(e??1)+(t??1)}Lr(e,t,n,r=!1,i){if(!r||!n||!i){let n=e.Wt[1]>t.Wt[1]?e.Wt[1]:t.Wt[1],r=e.Wt[2]<t.Wt[2]?e.Wt[2]:t.Wt[2];return{Wr:e.$n,Hr:t.$n,Ur:e.wt,$r:t.wt,jr:e.Wt[0],qr:n,Yr:r,Kr:t.Wt[3],Gr:this.Fr(e.Gr,t.Gr),Zr:void 0,zr:!1}}let a=n(this.Xr(e,i),this.Xr(t,i)),o=i(a),s=o.length?o[o.length-1]:0;return{Wr:e.$n,Hr:t.$n,Ur:e.wt,$r:t.wt,jr:e.Wt[0],qr:Math.max(e.Wt[1],s),Yr:Math.min(e.Wt[2],s),Kr:s,Gr:this.Fr(e.Gr,t.Gr),Zr:a,zr:!1}}Nr(e,t,n,r=!1,i){if(!r||!n||!i)return{Wr:e.Wr,Hr:t.$n,Ur:e.Ur,$r:t.wt,jr:e.jr,qr:e.qr>t.Wt[1]?e.qr:t.Wt[1],Yr:e.Yr<t.Wt[2]?e.Yr:t.Wt[2],Kr:t.Wt[3],Gr:e.Gr+(t.Gr??1),Zr:e.Zr,zr:!1};let a=e.Zr,o=this.Xr(t,i),s=a?{data:a,index:e.Wr,originalTime:e.Ur,time:e.Ur,priceValues:i(a)}:null,c=s?n(s,o):o.data,l=s?i(c):o.priceValues,u=l.length?l[l.length-1]:0;return{Wr:e.Wr,Hr:t.$n,Ur:e.Ur,$r:t.wt,jr:e.jr,qr:Math.max(e.qr,u),Yr:Math.min(e.Yr,u),Kr:u,Gr:e.Gr+(t.Gr??1),Zr:c,zr:!1}}Jr(e,t,n,r,i,a,o=!1,s){let c=t===r?i:e[t];if(n-t==1)return this.Or(c,!0);let l=t+1===r?i:e[t+1],u=this.Lr(c,l,a,o,s);for(let c=t+2;c<n;c++){let t=c===r?i:e[c];u=this.Nr(u,t,a,o,s)}return u}Xr(e,t){let n=e.ue??{};return{data:e.ue,index:e.$n,originalTime:e.Qr,time:e.wt,priceValues:t(n)}}th(e,t=!1){let n=!0===t,r=!!e.Zr;return{$n:e.Wr,wt:e.Ur,Qr:e.Ur,Wt:[n?e.Kr:e.jr,e.qr,e.Yr,e.Kr],Gr:e.Gr,ue:n?r?e.Zr:{wt:e.Ur}:void 0}}Ar(e,t=!1){return e.map((e=>this.th(e,t)))}Dr(e,t,n,r,i=!1,a,o){if(r.length===0)return r;let s=e.length-1,c=Math.floor(s/n)*n;if(Math.min(c+n,e.length)-c<n&&e.length>n){let r=e.slice();return r[r.length-1]=t,this.Cr(r,n,a,i,o)}if(Math.floor((s-1)/n)===Math.floor(s/n)||r.length===1){let l=Math.min(c+n,e.length),u=l-c;if(u<=0)return r;let d=u===1?this.Or(c===s?t:e[c],!0):this.Jr(e,c,l,s,t,a,i,o);return r[r.length-1]=this.th(d,i),r}{let r=e.slice();return r[r.length-1]=t,this.Cr(r,n,a,i,o)}}Or(e,t=!1){return{Wr:e.$n,Hr:e.$n,Ur:e.wt,$r:e.wt,jr:e.Wt[0],qr:e.Wt[1],Yr:e.Wt[2],Kr:e.Wt[3],Gr:e.Gr??1,Zr:e.ue,zr:t}}Pr(e){let t=this.ih(e),n=this.Ir(e);return t.nh!==n&&(t.kr.clear(),t.nh=n),t}ih(e){let t=this.br.get(e);return t===void 0&&(t={nh:this.Ir(e),kr:new Map},this.br.set(e,t)),t}},zC=class extends sC{constructor(e){super(),this.sn=e}Qt(){return this.sn}},BC={Bar:(e,t,n,r)=>{let i=t.upColor,a=t.downColor,o=$(e(n,r)),s=ES(o.Wt[0])<=ES(o.Wt[3]);return{sh:o.R??(s?i:a)}},Candlestick:(e,t,n,r)=>{let i=t.upColor,a=t.downColor,o=t.borderUpColor,s=t.borderDownColor,c=t.wickUpColor,l=t.wickDownColor,u=$(e(n,r)),d=ES(u.Wt[0])<=ES(u.Wt[3]);return{sh:u.R??(d?i:a),eh:u.Ht??(d?o:s),rh:u.hh??(d?c:l)}},Custom:(e,t,n,r)=>({sh:$(e(n,r)).R??t.color}),Area:(e,t,n,r)=>{let i=$(e(n,r));return{sh:i.vt??t.lineColor,vt:i.vt??t.lineColor,ah:i.ah??t.topColor,oh:i.oh??t.bottomColor}},Baseline:(e,t,n,r)=>{let i=$(e(n,r));return{sh:i.Wt[3]>=t.baseValue.price?t.topLineColor:t.bottomLineColor,_h:i._h??t.topLineColor,uh:i.uh??t.bottomLineColor,dh:i.dh??t.topFillColor1,fh:i.fh??t.topFillColor2,ph:i.ph??t.bottomFillColor1,mh:i.mh??t.bottomFillColor2}},Line:(e,t,n,r)=>{let i=$(e(n,r));return{sh:i.R??t.color,vt:i.R??t.color}},Histogram:(e,t,n,r)=>({sh:$(e(n,r)).R??t.color})},VC=class{constructor(e){this.wh=(e,t)=>t===void 0?this.Te.Un().Mh(e):t.Wt,this.Te=e,this.gh=BC[e.bh()]}Sh(e,t){return this.gh(this.wh,this.Te.N(),e,t)}};function HC(e,t,n,r,i=0,a=t.length){let o=a-i;for(;0<o;){let a=o>>1,s=i+a;r(t[s],n)===e?(i=s+1,o-=a+1):o=a}return i}var UC=HC.bind(null,!0),WC=HC.bind(null,!1),GC;(function(e){e[e.NearestLeft=-1]=`NearestLeft`,e[e.None=0]=`None`,e[e.NearestRight=1]=`NearestRight`})(GC||={});var KC=30,qC=class{constructor(){this.xh=[],this.Ch=new Map,this.yh=new Map,this.Ph=[]}kh(){return this.Th()>0?this.xh[this.xh.length-1]:null}Rh(){return this.Th()>0?this.Dh(0):null}Qn(){return this.Th()>0?this.Dh(this.xh.length-1):null}Th(){return this.xh.length}Zi(){return this.Th()===0}ze(e){return this.Ih(e,0)!==null}Mh(e){return this.Hn(e)}Hn(e,t=0){let n=this.Ih(e,t);return n===null?null:{...this.Vh(n),$n:this.Dh(n)}}Bh(){return this.xh}Eh(e,t,n){if(this.Zi())return null;let r=null;for(let i of n)r=JC(r,this.Ah(e,t,i));return r}ht(e){this.yh.clear(),this.Ch.clear(),this.xh=e,this.Ph=e.map((e=>e.$n))}Lh(){return this.Ph}Dh(e){return this.xh[e].$n}Vh(e){return this.xh[e]}Ih(e,t){let n=this.zh(e);if(n===null&&t!==0)switch(t){case-1:return this.Oh(e);case 1:return this.Nh(e);default:throw TypeError(`Unknown search mode`)}return n}Oh(e){let t=this.Fh(e);return t>0&&--t,t!==this.xh.length&&this.Dh(t)<e?t:null}Nh(e){let t=this.Wh(e);return t!==this.xh.length&&e<this.Dh(t)?t:null}zh(e){let t=this.Fh(e);return t===this.xh.length||e<this.xh[t].$n?null:t}Fh(e){return UC(this.xh,e,((e,t)=>e.$n<t))}Wh(e){return WC(this.xh,e,((e,t)=>e.$n>t))}Hh(e,t,n){let r=null;for(let i=e;i<t;i++){let e=this.xh[i].Wt[n];Number.isNaN(e)||(r===null?r={Uh:e,$h:e}:(e<r.Uh&&(r.Uh=e),e>r.$h&&(r.$h=e)))}return r}Ah(e,t,n){if(this.Zi())return null;let r=null,i=$(this.Rh()),a=$(this.Qn()),o=Math.max(e,i),s=Math.min(t,a),c=Math.ceil(o/KC)*KC,l=Math.max(c,Math.floor(s/KC)*KC);{let e=this.Fh(o),i=this.Wh(Math.min(s,c,t));r=JC(r,this.Hh(e,i,n))}let u=this.Ch.get(n);u===void 0&&(u=new Map,this.Ch.set(n,u));for(let e=Math.max(c+1,o);e<l;e+=KC){let t=Math.floor(e/KC),i=u.get(t);if(i===void 0){let e=this.Fh(t*KC),r=this.Wh((t+1)*KC-1);i=this.Hh(e,r,n),u.set(t,i)}r=JC(r,i)}{let e=this.Fh(l),t=this.Wh(s);r=JC(r,this.Hh(e,t,n))}return r}};function JC(e,t){return e===null?t:t===null?e:{Uh:Math.min(e.Uh,t.Uh),$h:Math.max(e.$h,t.$h)}}function YC(){return new qC}var XC={setLineStyle:SS},ZC=class{constructor(e){this.jh=e}st(e,t,n){this.jh.draw(e,XC)}qh(e,t,n){this.jh.drawBackground?.(e,XC)}},QC=class{constructor(e){this.Ls=null,this.Yh=e}Tt(){let e=this.Yh.renderer();if(e===null)return null;if(this.Ls?.Kh===e)return this.Ls.Gh;let t=new ZC(e);return this.Ls={Kh:e,Gh:t},t}Zh(){return this.Yh.zOrder?.()??`normal`}},$C=class{constructor(e){this.Xh=null,this.Jh=e}Qh(){return this.Jh}Nn(){this.Jh.updateAllViews?.()}jn(){let e=this.Jh.paneViews?.()??[];if(this.Xh?.Kh===e)return this.Xh.Gh;let t=e.map((e=>new QC(e)));return this.Xh={Kh:e,Gh:t},t}Qs(e,t){return this.Jh.hitTest?.(e,t)??null}},ew=class extends $C{cn(){return[]}},tw=class{constructor(e){this.jh=e}st(e,t,n){this.jh.draw(e,XC)}qh(e,t,n){this.jh.drawBackground?.(e,XC)}},nw=class{constructor(e){this.Ls=null,this.Yh=e}Tt(){let e=this.Yh.renderer();if(e===null)return null;if(this.Ls?.Kh===e)return this.Ls.Gh;let t=new tw(e);return this.Ls={Kh:e,Gh:t},t}Zh(){return this.Yh.zOrder?.()??`normal`}};function rw(e){return{ri:e.text(),Ei:e.coordinate(),Vi:e.fixedCoordinate?.(),R:e.textColor(),Z:e.backColor(),It:e.visible?.()??!0,pi:e.tickVisible?.()??!0}}var iw=class{constructor(e,t){this.Xt=new aC,this.ta=e,this.ia=t}Tt(){return this.Xt.ht({nn:this.ia.nn(),...rw(this.ta)}),this.Xt}},aw=class extends nC{constructor(e,t){super(),this.ta=e,this.Ki=t}Yi(e,t,n){let r=rw(this.ta);n.Z=r.Z,e.R=r.R;let i=2/12*this.Ki.P();n.Ti=i,n.Ri=i,n.Ei=r.Ei,n.Vi=r.Vi,e.ri=r.ri,e.It=r.It,e.pi=r.pi}},ow=class extends $C{constructor(e,t){super(e),this.na=null,this.sa=null,this.ea=null,this.ra=null,this.Te=t}dn(){let e=this.Jh.timeAxisViews?.()??[];if(this.na?.Kh===e)return this.na.Gh;let t=this.Te.Qt().Et(),n=e.map((e=>new iw(e,t)));return this.na={Kh:e,Gh:n},n}qn(){let e=this.Jh.priceAxisViews?.()??[];if(this.sa?.Kh===e)return this.sa.Gh;let t=this.Te.Ft(),n=e.map((e=>new aw(e,t)));return this.sa={Kh:e,Gh:n},n}ha(){let e=this.Jh.priceAxisPaneViews?.()??[];if(this.ea?.Kh===e)return this.ea.Gh;let t=e.map((e=>new nw(e)));return this.ea={Kh:e,Gh:t},t}aa(){let e=this.Jh.timeAxisPaneViews?.()??[];if(this.ra?.Kh===e)return this.ra.Gh;let t=e.map((e=>new nw(e)));return this.ra={Kh:e,Gh:t},t}la(e,t){return this.Jh.autoscaleInfo?.(e,t)??null}};function sw(e,t,n,r){e.forEach((e=>{t(e).forEach((e=>{e.Zh()===n&&r.push(e)}))}))}function cw(e){return e.jn()}function lw(e){return e.ha()}function uw(e){return e.aa()}var dw=[`Area`,`Line`,`Baseline`],fw=class extends zC{constructor(e,t,n,r,i){super(e),this.qt=YC(),this.dr=new OC(this),this.oa=[],this._a=new wC(this),this.ua=null,this.ca=null,this.da=null,this.fa=[],this.pa=new RC,this.va=new Map,this.ma=null,this.yn=n,this.wa=t;let a=new kC(this);if(this.mn=[a],this.pr=new xC(a,this,e),dw.includes(this.wa)&&(this.ua=new DC(this)),this.Ma(),this.Yh=r(this,this.Qt(),i),this.wa===`Custom`){let e=this.Yh;e.ga&&this.ba(e.ga)}}m(){this.da!==null&&clearTimeout(this.da)}We(e){return this.yn.priceLineColor||e}Ae(e){let t={Le:!0},n=this.Ft();if(this.Qt().Et().Zi()||n.Zi()||this.qt.Zi())return t;let r=this.Qt().Et().Ee(),i=this.Lt();if(r===null||i===null)return t;let a,o;if(e){let e=this.qt.kh();if(e===null)return t;a=e,o=e.$n}else{let e=this.qt.Hn(r.bi(),-1);if(e===null||(a=this.qt.Mh(e.$n),a===null))return t;o=e.$n}let s=a.Wt[3],c=this.Sa().Sh(o,{Wt:a}),l=n.Nt(s,i.Wt);return{Le:!1,Mt:s,ri:n.Ji(s,i.Wt),qe:n.xa(s),Ye:n.Ca(s,i.Wt),R:c.sh,Ei:l,$n:o}}Sa(){return this.ca!==null||(this.ca=new VC(this)),this.ca}N(){return this.yn}vr(e){let t=this.Qt(),{priceScaleId:n,visible:r,priceFormat:i}=e;n!==void 0&&n!==this.yn.priceScaleId&&t.ya(this,n),r!==void 0&&r!==this.yn.visible&&t.Pa();let a=e.conflationThresholdFactor!==void 0;OS(this.yn,e),Object.prototype.hasOwnProperty.call(e,`autoscaleInfoProvider`)&&e.autoscaleInfoProvider===void 0&&(this.yn.autoscaleInfoProvider=void 0),a&&(this.va.clear(),this.Qt().mr()),i!==void 0&&(this.Ma(),t.ka()),t.Ta(this),t.Ra(),this.Yh.Pt(`options`)}ht(e,t){this.qt.ht(e),this.va.clear();let n=this.Qt().Et().N();n.enableConflation&&n.precomputeConflationOnInit&&this.Da(n.precomputeConflationPriority),this.Ia(),this.ua!==null&&(t&&t.Va?this.ua.De():e.length===0&&this.ua.Re());let r=this.Qt().Ks(this);this.Qt().Ba(r),this.Qt().Ta(this),this.Qt().Ra(),this.Qt().mr()}Ia(){this.Yh.Pt(`data`)}Ea(e){let t=new LC(this,e);return this.oa.push(t),this.Qt().Ta(this),t}Aa(e){let t=this.oa.indexOf(e);t!==-1&&this.oa.splice(t,1),this.Qt().Ta(this)}La(){return this.oa}bh(){return this.wa}Lt(){let e=this.za();return e===null?null:{Wt:e.Wt[3],Oa:e.wt}}za(){let e=this.Qt().Et().Ee();if(e===null)return null;let t=e.Na();return this.qt.Hn(t,1)}Un(){return this.qt}ba(e){this.ma=e,this.va.clear()}Fa(){return!!this.Qt().Et().N().enableConflation&&this.Wa()>1}Rr(e){if(!this.Fa())return;let t=this.Wa();if(!this.va.has(t))return;let n=this.wa===`Custom`,r=n&&this.ma||void 0,i=n&&this.Yh.Ha?e=>{let t=e,n=this.Yh.Ha(t);return Array.isArray(n)?n:[typeof n==`number`?n:0]}:void 0,a=this.pa.Rr(this.qt.Bh(),e,t,r,n,i),o=YC();o.ht(a),this.va.set(t,o)}Ua(){let e=this.Qt().Et().N().enableConflation;if(this.wa===`Custom`&&this.ma===null||!e)return this.qt;let t=this.Wa();return this.va.get(t)||(this.$a(t),this.va.get(t)??this.qt)}ja(e){let t=this.qt.Mh(e);return t===null?null:this.wa===`Bar`||this.wa===`Candlestick`||this.wa===`Custom`?{jr:t.Wt[0],qr:t.Wt[1],Yr:t.Wt[2],Kr:t.Wt[3]}:t.Wt[3]}qa(e){let t=[];sw(this.fa,cw,`top`,t);let n=this.ua;return n!==null&&n.It()&&(this.da===null&&n.Ve()&&(this.da=setTimeout((()=>{this.da=null,this.Qt().Ya()}),0)),n.Ie(),t.unshift(n)),t}jn(){let e=[];this.Ka()||e.push(this._a),e.push(this.Yh,this.dr);let t=this.oa.map((e=>e.wr()));return e.push(...t),sw(this.fa,cw,`normal`,e),e}Ga(){let e=this.Yh.Ga?.()??null;if(e===null)return null;let t=[];this.Ka()||t.push(this._a),t.push(...e.Za),sw(this.fa,cw,`normal`,t);let n=[];n.push(...e.qa,this.dr);let r=this.oa.map((e=>e.wr()));return n.push(...r),{Za:t,qa:n}}Xa(){return this.Ja(cw,`bottom`)}Qa(e){return this.Ja(lw,e)}tl(e){return this.Ja(uw,e)}il(e,t){return this.fa.map((n=>n.Qs(e,t))).filter((e=>e!==null))}cn(){return[this.pr,...this.oa.map((e=>e.Mr()))]}qn(e,t){if(t!==this.hn&&!this.Ka())return[];let n=[...this.mn];for(let e of this.oa)n.push(e.gr());return this.fa.forEach((e=>{n.push(...e.qn())})),n}dn(){let e=[];return this.fa.forEach((t=>{e.push(...t.dn())})),e}la(e,t){if(this.yn.autoscaleInfoProvider!==void 0){let n=this.yn.autoscaleInfoProvider((()=>{let n=this.nl(e,t);return n===null?null:n.sr()}));return MC.er(n)}return this.nl(e,t)}Kh(){let e=this.yn.priceFormat;return e.base??1/e.minMove}sl(){return this.el}Nn(){this.Yh.Pt();for(let e of this.mn)e.Pt();for(let e of this.oa)e.Pt();this.dr.Pt(),this._a.Pt(),this.ua?.Pt(),this.fa.forEach((e=>e.Nn()))}Ft(){return $(super.Ft())}At(e){if(this.wa!==`Line`&&this.wa!==`Area`&&this.wa!==`Baseline`||!this.yn.crosshairMarkerVisible)return null;let t=this.qt.Mh(e);return t===null?null:{Mt:t.Wt[3],ft:this.rl(),Ht:this.hl(),Ot:this.al(),zt:this.ll(e)}}He(){return this.yn.title}It(){return this.yn.visible}ol(e){this.fa.push(new ow(e,this))}_l(e){this.fa=this.fa.filter((t=>t.Qh()!==e))}ul(){if(this.wa===`Custom`)return e=>this.Yh.Ha(e)}cl(){if(this.wa===`Custom`)return e=>this.Yh.dl(e)}fl(){return this.qt.Lh()}Ka(){return!uC(this.Ft().pl())}nl(e,t){if(!AS(e)||!AS(t)||this.qt.Zi())return null;let n=this.wa===`Line`||this.wa===`Area`||this.wa===`Baseline`||this.wa===`Histogram`?[3]:[2,1],r=this.qt.Eh(e,t,n),i=r===null?null:new jC(r.Uh,r.$h),a=null;if(this.bh()===`Histogram`){let e=this.yn.base,t=new jC(e,e);i=i===null?t:i.Ss(t)}return this.fa.forEach((n=>{let r=n.la(e,t);if(r?.priceRange){let e=new jC(r.priceRange.minValue,r.priceRange.maxValue);i=i===null?e:i.Ss(e)}r?.margins&&(a=r.margins)})),new MC(i,a)}rl(){switch(this.wa){case`Line`:case`Area`:case`Baseline`:return this.yn.crosshairMarkerRadius}return 0}hl(){switch(this.wa){case`Line`:case`Area`:case`Baseline`:{let e=this.yn.crosshairMarkerBorderColor;if(e.length!==0)return e}}return null}al(){switch(this.wa){case`Line`:case`Area`:case`Baseline`:return this.yn.crosshairMarkerBorderWidth}return 0}ll(e){switch(this.wa){case`Line`:case`Area`:case`Baseline`:{let e=this.yn.crosshairMarkerBackgroundColor;if(e.length!==0)return e}}return this.Sa().Sh(e).sh}Ma(){switch(this.yn.priceFormat.type){case`custom`:{let e=this.yn.priceFormat.formatter;this.el={format:e,formatTickmarks:this.yn.priceFormat.tickmarksFormatter??(t=>t.map(e))};break}case`volume`:this.el=new _C(this.yn.priceFormat.precision);break;case`percent`:this.el=new gC(this.yn.priceFormat.precision);break;default:{let e=10**this.yn.priceFormat.precision;this.el=new hC(e,this.yn.priceFormat.minMove*e)}}this.hn!==null&&this.hn.vl()}Ja(e,t){let n=[];return sw(this.fa,e,t,n),n}Wa(){let{ml:e,wl:t,Ml:n}=this.gl();return this.pa.Sr(e,t,n)}gl(){let e=this.Qt().Et(),t=e.ml(),n=window.devicePixelRatio||1,r=e.N().conflationThresholdFactor;return{ml:t,wl:n,Ml:this.yn.conflationThresholdFactor??r??1}}bl(e){let t=this.qt.Bh(),n;if(this.wa===`Custom`&&this.ma!==null){let r=this.ul();if(!r)throw Error(PC);n=this.pa.Cr(t,e,this.ma,!0,(e=>r(e)))}else n=this.pa.Cr(t,e);let r=YC();return r.ht(n),r}$a(e){let t=this.bl(e);this.va.set(e,t)}Da(e){if(this.wa===`Custom`&&(this.ma===null||!this.ul()))return;this.va.clear();let t=this.Qt().Et().Sl();for(let n of t){let t=()=>{this.xl(n)},r=typeof window==`object`&&window||typeof self==`object`&&self;r?.yl?.Cl?r.yl.Cl((()=>{t()}),{se:e}):Promise.resolve().then((()=>t()))}}xl(e){if(this.va.has(e)||this.qt.Bh().length===0)return;let t=this.bl(e);this.va.set(e,t)}},pw=[3],mw=[0,1,2,3],hw=class{constructor(e){this.yn=e}Pl(e,t,n){let r=e;if(this.yn.mode===0)return r;let i=n.kn(),a=i.Lt();if(a===null)return r;let o=i.Nt(e,a),s=n.kl().filter((e=>e instanceof fw)).reduce(((e,r)=>{if(n.Gs(r)||!r.It())return e;let i=r.Ft(),a=r.Un();if(i.Zi()||!a.ze(t))return e;let o=a.Mh(t);if(o===null)return e;let s=ES(r.Lt()),c=this.yn.mode===3?mw:pw;return e.concat(c.map((e=>i.Nt(o.Wt[e],s.Wt))))}),[]);if(s.length===0)return r;s.sort(((e,t)=>Math.abs(e-o)-Math.abs(t-o)));let c=s[0];return r=i.Tn(c,a),r}};function gw(e,t,n){return Math.min(Math.max(e,t),n)}function _w(e,t,n){return t-e<=n}var vw=class extends US{constructor(){super(...arguments),this.qt=null}ht(e){this.qt=e}et({context:e,bitmapSize:t,horizontalPixelRatio:n,verticalPixelRatio:r}){if(this.qt===null)return;let i=Math.max(1,Math.floor(n));e.lineWidth=i,function(e,t){e.save(),e.lineWidth%2&&e.translate(.5,.5),t(),e.restore()}(e,(()=>{let a=$(this.qt);if(a.Tl){e.strokeStyle=a.Rl,SS(e,a.Dl),e.beginPath();for(let r of a.Il){let a=Math.round(r.Vl*n);e.moveTo(a,-i),e.lineTo(a,t.height+i)}e.stroke()}if(a.Bl){e.strokeStyle=a.El,SS(e,a.Al),e.beginPath();for(let n of a.Ll){let a=Math.round(n.Vl*r);e.moveTo(-i,a),e.lineTo(t.width+i,a)}e.stroke()}}))}},yw=class{constructor(e){this.Xt=new vw,this.xt=!0,this.yt=e}Pt(){this.xt=!0}Tt(){if(this.xt){let e=this.yt.Qt().N().grid,t={Bl:e.horzLines.visible,Tl:e.vertLines.visible,El:e.horzLines.color,Rl:e.vertLines.color,Al:e.horzLines.style,Dl:e.vertLines.style,Ll:this.yt.kn().zl(),Il:(this.yt.Qt().Et().zl()||[]).map((e=>({Vl:e.coord})))};this.Xt.ht(t),this.xt=!1}return this.Xt}},bw=class{constructor(e){this.Yh=new yw(e)}wr(){return this.Yh}},xw={Ol:4,Nl:1e-4};function Sw(e,t){let n=100*(e-t)/t;return t<0?-n:n}function Cw(e,t){return new jC(Sw(e.Je(),t),Sw(e.Qe(),t))}function ww(e,t){let n=100*(e-t)/t+100;return t<0?-n:n}function Tw(e,t){return new jC(ww(e.Je(),t),ww(e.Qe(),t))}function Ew(e,t){let n=Math.abs(e);if(n<1e-15)return 0;let r=Math.log10(n+t.Nl)+t.Ol;return e<0?-r:r}function Dw(e,t){let n=Math.abs(e);if(n<1e-15)return 0;let r=10**(n-t.Ol)-t.Nl;return e<0?-r:r}function Ow(e,t){return e===null?null:new jC(Ew(e.Je(),t),Ew(e.Qe(),t))}function kw(e,t){return e===null?null:new jC(Dw(e.Je(),t),Dw(e.Qe(),t))}function Aw(e){if(e===null)return xw;let t=Math.abs(e.Qe()-e.Je());if(t>=1||t<1e-15)return xw;let n=Math.ceil(Math.abs(Math.log10(t))),r=xw.Ol+n;return{Ol:r,Nl:1/10**r}}var jw=class{constructor(e,t){if(this.Fl=e,this.Wl=t,function(e){if(e<0)return!1;if(e>0xde0b6b3a7640000)return!0;for(let t=e;t>1;t/=10)if(t%10!=0)return!1;return!0}(this.Fl))this.Hl=[2,2.5,2];else{this.Hl=[];for(let e=this.Fl;e!==1;){if(e%2==0)this.Hl.push(2),e/=2;else{if(e%5!=0)throw Error(`unexpected base`);this.Hl.push(2,2.5),e/=5}if(this.Hl.length>100)throw Error(`something wrong with base`)}}}Ul(e,t,n){let r=this.Fl===0?0:1/this.Fl,i=10**Math.max(0,Math.ceil(Math.log10(e-t))),a=0,o=this.Wl[0];for(;;){let e=_w(i,r,1e-14)&&i>r+1e-14,t=_w(i,n*o,1e-14),s=_w(i,1,1e-14);if(!(e&&t&&s))break;i/=o,o=this.Wl[++a%this.Wl.length]}if(i<=r+1e-14&&(i=r),i=Math.max(1,i),this.Hl.length>0&&(s=i,c=1,l=1e-14,Math.abs(s-c)<l))for(a=0,o=this.Hl[0];_w(i,n*o,1e-14)&&i>r+1e-14;)i/=o,o=this.Hl[++a%this.Hl.length];var s,c,l;return i}},Mw=class{constructor(e,t,n,r){this.$l=[],this.Ki=e,this.Fl=t,this.jl=n,this.ql=r}Ul(e,t){if(e<t)throw Error(`high < low`);let n=this.Ki.$t(),r=(e-t)*this.Yl()/n,i=new jw(this.Fl,[2,2.5,2]),a=new jw(this.Fl,[2,2,2.5]),o=new jw(this.Fl,[2.5,2,2]),s=[];return s.push(i.Ul(e,t,r),a.Ul(e,t,r),o.Ul(e,t,r)),function(e){if(e.length<1)throw Error(`array is empty`);let t=e[0];for(let n=1;n<e.length;++n)e[n]<t&&(t=e[n]);return t}(s)}Kl(){let e=this.Ki,t=e.Lt();if(t===null)return void(this.$l=[]);let n=e.$t(),r=this.jl(n-1,t),i=this.jl(0,t),a=this.Ki.N().entireTextOnly?this.Gl()/2:0,o=a,s=n-1-a,c=Math.max(r,i),l=Math.min(r,i);if(c===l)return void(this.$l=[]);let u=this.Ul(c,l);if(this.Zl(t,u,c,l,o,s),e.Xl()&&this.Jl(u,l,c)){let e=this.Ki.Ql();this.io(t,u,o,s,e,2*e)}let d=this.$l.map((e=>e.no)),f=this.Ki.so(d);for(let e=0;e<this.$l.length;e++)this.$l[e].eo=f[e]}zl(){return this.$l}Gl(){return this.Ki.P()}Yl(){return Math.ceil(this.Gl()*this.Ki.N().tickMarkDensity)}Zl(e,t,n,r,i,a){let o=this.$l,s=this.Ki,c=n%t;c+=c<0?t:0;let l=n>=r?1:-1,u=null,d=0;for(let f=n-c;f>r;f-=t){let n=this.ql(f,e,!0);u!==null&&Math.abs(n-u)<this.Yl()||n<i||n>a||(d<o.length?(o[d].Vl=n,o[d].eo=s.ro(f),o[d].no=f):o.push({Vl:n,eo:s.ro(f),no:f}),d++,u=n,s.ho()&&(t=this.Ul(f*l,r)))}o.length=d}io(e,t,n,r,i,a){let o=this.$l,s=this.ao(e,n,i,a),c=this.ao(e,r,-a,-i),l=this.ql(0,e,!0)-this.ql(t,e,!0);o.length>0&&o[0].Vl-s.Vl<l/2&&o.shift(),o.length>0&&c.Vl-o[o.length-1].Vl<l/2&&o.pop(),o.unshift(s),o.push(c)}ao(e,t,n,r){let i=(n+r)/2,a=this.jl(t+n,e),o=this.jl(t+r,e),s=Math.min(a,o),c=Math.max(a,o),l=Math.max(.1,this.Ul(c,s)),u=this.jl(t+i,e),d=u-u%l,f=this.ql(d,e,!0);return{eo:this.Ki.ro(d),Vl:f,no:d}}Jl(e,t,n){let r=ES(this.Ki.ar());return this.Ki.ho()&&(r=kw(r,this.Ki.lo())),r.Je()-t<e&&n-r.Qe()<e}};function Nw(e){return e.slice().sort(((e,t)=>$(e.ln())-$(t.ln())))}var Pw;(function(e){e[e.Normal=0]=`Normal`,e[e.Logarithmic=1]=`Logarithmic`,e[e.Percentage=2]=`Percentage`,e[e.IndexedTo100=3]=`IndexedTo100`})(Pw||={});var Fw=new gC,Iw=new hC(100,1),Lw=class{constructor(e,t,n,r,i){this.oo=0,this._o=null,this.rr=null,this.uo=null,this.co={do:!1,fo:null},this.po=!1,this.vo=0,this.mo=0,this.wo=new DS,this.Mo=new DS,this.bo=[],this.So=null,this.xo=null,this.Co=null,this.yo=null,this.Po=null,this.el=Iw,this.ko=Aw(null),this.To=e,this.yn=t,this.Ro=n,this.Do=r,this.Io=i,this.Vo=new Mw(this,100,this.Bo.bind(this),this.Eo.bind(this))}pl(){return this.To}N(){return this.yn}vr(e){if(OS(this.yn,e),this.vl(),e.mode!==void 0&&this.Ao({_e:e.mode}),e.scaleMargins!==void 0){let t=TS(e.scaleMargins.top),n=TS(e.scaleMargins.bottom);if(t<0||t>1)throw Error(`Invalid top margin - expect value between 0 and 1, given=${t}`);if(n<0||n>1)throw Error(`Invalid bottom margin - expect value between 0 and 1, given=${n}`);if(t+n>1)throw Error(`Invalid margins - sum of margins must be less than 1, given=${t+n}`);this.Lo(),this.Co=null}}zo(){return this.yn.autoScale}Oo(){return this.po}ho(){return this.yn.mode===1}je(){return this.yn.mode===2}No(){return this.yn.mode===3}lo(){return this.ko}_e(){return{hs:this.yn.autoScale,Fo:this.yn.invertScale,_e:this.yn.mode}}Ao(e){let t=this._e(),n=null;e.hs!==void 0&&(this.yn.autoScale=e.hs),e._e!==void 0&&(this.yn.mode=e._e,e._e!==2&&e._e!==3||(this.yn.autoScale=!0),this.co.do=!1),t._e===1&&e._e!==t._e&&(function(e,t){if(e===null)return!1;let n=Dw(e.Je(),t),r=Dw(e.Qe(),t);return isFinite(n)&&isFinite(r)}(this.rr,this.ko)?(n=kw(this.rr,this.ko),n!==null&&this.Wo(n)):this.yn.autoScale=!0),e._e===1&&e._e!==t._e&&(n=Ow(this.rr,this.ko),n!==null&&this.Wo(n));let r=t._e!==this.yn.mode;r&&(t._e===2||this.je())&&this.vl(),r&&(t._e===3||this.No())&&this.vl(),e.Fo!==void 0&&t.Fo!==e.Fo&&(this.yn.invertScale=e.Fo,this.Ho()),this.Mo.p(t,this._e())}Uo(){return this.Mo}P(){return this.Ro.fontSize}$t(){return this.oo}$o(e){this.oo!==e&&(this.oo=e,this.Lo(),this.Co=null)}jo(){if(this._o)return this._o;let e=this.$t()-this.qo()-this.Yo();return this._o=e,e}ar(){return this.Ko(),this.rr}Wo(e,t){let n=this.rr;(t||n===null&&e!==null||n!==null&&!n.Ze(e))&&(this.Co=null,this.rr=e)}Go(e){this.Wo(e),this.Zo(e!==null)}Zi(){return this.Ko(),this.oo===0||!this.rr||this.rr.Zi()}Xo(e){return this.Fo()?e:this.$t()-1-e}Nt(e,t){return this.je()?e=Sw(e,t):this.No()&&(e=ww(e,t)),this.Eo(e,t)}Jo(e,t,n){this.Ko();let r=this.Yo(),i=$(this.ar()),a=i.Je(),o=i.Qe(),s=this.jo()-1,c=this.Fo(),l=s/(o-a),u=n===void 0?0:n.from,d=n===void 0?e.length:n.to,f=this.Qo();for(let n=u;n<d;n++){let i=e[n],o=i.Mt;if(isNaN(o))continue;let s=o;f!==null&&(s=f(i.Mt,t));let u=r+l*(s-a);i.ut=c?u:this.oo-1-u}}t_(e,t,n){this.Ko();let r=this.Yo(),i=$(this.ar()),a=i.Je(),o=i.Qe(),s=this.jo()-1,c=this.Fo(),l=s/(o-a),u=n===void 0?0:n.from,d=n===void 0?e.length:n.to,f=this.Qo();for(let n=u;n<d;n++){let i=e[n],o=i.jr,s=i.qr,u=i.Yr,d=i.Kr;f!==null&&(o=f(i.jr,t),s=f(i.qr,t),u=f(i.Yr,t),d=f(i.Kr,t));let p=r+l*(o-a),m=c?p:this.oo-1-p;i.i_=m,p=r+l*(s-a),m=c?p:this.oo-1-p,i.n_=m,p=r+l*(u-a),m=c?p:this.oo-1-p,i.s_=m,p=r+l*(d-a),m=c?p:this.oo-1-p,i.e_=m}}Tn(e,t){let n=this.Bo(e,t);return this.r_(n,t)}r_(e,t){let n=e;return this.je()?n=function(e,t){return t<0&&(e=-e),e/100*t+t}(n,t):this.No()&&(n=function(e,t){return e-=100,t<0&&(e=-e),e/100*t+t}(n,t)),n}kl(){return this.bo}Dt(){return this.xo||=Nw(this.bo),this.xo}h_(e){this.bo.indexOf(e)===-1&&(this.bo.push(e),this.vl(),this.a_())}l_(e){let t=this.bo.indexOf(e);if(t===-1)throw Error(`source is not attached to scale`);this.bo.splice(t,1),this.bo.length===0&&(this.Ao({hs:!0}),this.Wo(null)),this.vl(),this.a_()}Lt(){let e=null;for(let t of this.bo){let n=t.Lt();n!==null&&(e===null||n.Oa<e.Oa)&&(e=n)}return e===null?null:e.Wt}Fo(){return this.yn.invertScale}zl(){let e=this.Lt()===null;if(this.Co!==null&&(e||this.Co.o_===e))return this.Co.zl;this.Vo.Kl();let t=this.Vo.zl();return this.Co={zl:t,o_:e},this.wo.p(),t}__(){return this.wo}u_(e){this.je()||this.No()||this.yo===null&&this.uo===null&&(this.Zi()||(this.yo=this.oo-e,this.uo=$(this.ar()).Xe()))}c_(e){if(this.je()||this.No()||this.yo===null)return;this.Ao({hs:!1}),(e=this.oo-e)<0&&(e=0);let t=(this.yo+.2*(this.oo-1))/(e+.2*(this.oo-1)),n=$(this.uo).Xe();t=Math.max(t,.1),n.ir(t),this.Wo(n)}d_(){this.je()||this.No()||(this.yo=null,this.uo=null)}f_(e){this.zo()||this.Po===null&&this.uo===null&&(this.Zi()||(this.Po=e,this.uo=$(this.ar()).Xe()))}p_(e){if(this.zo()||this.Po===null)return;let t=$(this.ar()).tr()/(this.jo()-1),n=e-this.Po;this.Fo()&&(n*=-1);let r=n*t,i=$(this.uo).Xe();i.nr(r),this.Wo(i,!0),this.Co=null}v_(){this.zo()||this.Po!==null&&(this.Po=null,this.uo=null)}sl(){return this.el||this.vl(),this.el}Ji(e,t){switch(this.yn.mode){case 2:return this.m_(Sw(e,t));case 3:return this.sl().format(ww(e,t));default:return this.cr(e)}}ro(e){switch(this.yn.mode){case 2:return this.m_(e);case 3:return this.sl().format(e);default:return this.cr(e)}}so(e){switch(this.yn.mode){case 2:return this.w_(e);case 3:return this.sl().formatTickmarks(e);default:return this.M_(e)}}xa(e){return this.cr(e,$(this.So).sl())}Ca(e,t){return e=Sw(e,t),this.m_(e,Fw)}g_(){return this.bo}b_(e){this.co={fo:e,do:!1}}Nn(){this.bo.forEach((e=>e.Nn()))}Xl(){return this.yn.ensureEdgeTickMarksVisible&&this.zo()}Ql(){return this.P()/2}vl(){this.Co=null;let e=1/0;this.So=null;for(let t of this.bo)t.ln()<e&&(e=t.ln(),this.So=t);let t=100;this.So!==null&&(t=Math.round(this.So.Kh())),this.el=Iw,this.je()?(this.el=Fw,t=100):this.No()?(this.el=new hC(100,1),t=100):this.So!==null&&(this.el=this.So.sl()),this.Vo=new Mw(this,t,this.Bo.bind(this),this.Eo.bind(this)),this.Vo.Kl()}a_(){this.xo=null}S_(){return this.So===null||this.je()||this.No()?1:1/this.So.Kh()}Xi(){return this.Io}Zo(e){this.po=e}qo(){return this.Fo()?this.yn.scaleMargins.bottom*this.$t()+this.mo:this.yn.scaleMargins.top*this.$t()+this.vo}Yo(){return this.Fo()?this.yn.scaleMargins.top*this.$t()+this.vo:this.yn.scaleMargins.bottom*this.$t()+this.mo}Ko(){this.co.do||(this.co.do=!0,this.x_())}Lo(){this._o=null}Eo(e,t){if(this.Ko(),this.Zi())return 0;e=this.ho()&&e?Ew(e,this.ko):e;let n=$(this.ar()),r=this.Yo()+(this.jo()-1)*(e-n.Je())/n.tr();return this.Xo(r)}Bo(e,t){if(this.Ko(),this.Zi())return 0;let n=this.Xo(e),r=$(this.ar()),i=r.Je()+r.tr()*((n-this.Yo())/(this.jo()-1));return this.ho()?Dw(i,this.ko):i}Ho(){this.Co=null,this.Vo.Kl()}x_(){if(this.Oo()&&!this.zo())return;let e=this.co.fo;if(e===null)return;let t=null,n=this.g_(),r=0,i=0;for(let a of n){if(!a.It())continue;let n=a.Lt();if(n===null)continue;let o=a.la(e.Na(),e.bi()),s=o&&o.ar();if(s!==null){switch(this.yn.mode){case 1:s=Ow(s,this.ko);break;case 2:s=Cw(s,n.Wt);break;case 3:s=Tw(s,n.Wt)}if(t=t===null?s:t.Ss($(s)),o!==null){let e=o.lr();e!==null&&(r=Math.max(r,e.above),i=Math.max(i,e.below))}}}if(this.Xl()&&(r=Math.max(r,this.Ql()),i=Math.max(i,this.Ql())),r===this.vo&&i===this.mo||(this.vo=r,this.mo=i,this.Co=null,this.Lo()),t!==null){if(t.Je()===t.Qe()){let e=5*this.S_();this.ho()&&(t=kw(t,this.ko)),t=new jC(t.Je()-e,t.Qe()+e),this.ho()&&(t=Ow(t,this.ko))}if(this.ho()){let e=kw(t,this.ko),n=Aw(e);if(a=n,o=this.ko,a.Ol!==o.Ol||a.Nl!==o.Nl){let r=this.uo===null?null:kw(this.uo,this.ko);this.ko=n,t=Ow(e,n),r!==null&&(this.uo=Ow(r,n))}}this.Wo(t)}else this.rr===null&&(this.Wo(new jC(-.5,.5)),this.ko=Aw(null));var a,o}Qo(){return this.je()?Sw:this.No()?ww:this.ho()?e=>Ew(e,this.ko):null}C_(e,t,n){return t===void 0?(n===void 0&&(n=this.sl()),n.format(e)):t(e)}y_(e,t,n){return t===void 0?(n===void 0&&(n=this.sl()),n.formatTickmarks(e)):t(e)}cr(e,t){return this.C_(e,this.Do.priceFormatter,t)}M_(e,t){let n=this.Do.priceFormatter;return this.y_(e,this.Do.tickmarksPriceFormatter??(n?e=>e.map(n):void 0),t)}m_(e,t){return this.C_(e,this.Do.percentageFormatter,t)}w_(e,t){let n=this.Do.percentageFormatter;return this.y_(e,this.Do.tickmarksPercentageFormatter??(n?e=>e.map(n):void 0),t)}};function Rw(e){return e instanceof fw}var zw=class{constructor(e,t){this.bo=[],this.P_=new Map,this.oo=0,this.k_=0,this.T_=1,this.xo=null,this.R_=null,this.D_=!1,this.I_=new DS,this.fa=[],this.ia=e,this.sn=t,this.V_=new bw(this);let n=t.N();this.B_=this.E_(`left`,n.leftPriceScale),this.A_=this.E_(`right`,n.rightPriceScale),this.B_.Uo().i(this.L_.bind(this,this.B_),this),this.A_.Uo().i(this.L_.bind(this,this.A_),this),this.z_(n)}z_(e){if(e.leftPriceScale&&this.B_.vr(e.leftPriceScale),e.rightPriceScale&&this.A_.vr(e.rightPriceScale),e.localization&&(this.B_.vl(),this.A_.vl()),e.overlayPriceScales){let t=Array.from(this.P_.values());for(let n of t){let t=$(n[0].Ft());t.vr(e.overlayPriceScales),e.localization&&t.vl()}}}O_(e){switch(e){case`left`:return this.B_;case`right`:return this.A_}return this.P_.has(e)?TS(this.P_.get(e))[0].Ft():null}m(){this.Qt().N_().u(this),this.B_.Uo().u(this),this.A_.Uo().u(this),this.bo.forEach((e=>{e.m&&e.m()})),this.fa=this.fa.filter((e=>{let t=e.Qh();return t.detached&&t.detached(),!1})),this.I_.p()}F_(){return this.T_}W_(e){this.T_=e}Qt(){return this.sn}nn(){return this.k_}$t(){return this.oo}H_(e){this.k_=e,this.U_()}$o(e){this.oo=e,this.B_.$o(e),this.A_.$o(e),this.bo.forEach((t=>{if(this.Gs(t)){let n=t.Ft();n!==null&&n.$o(e)}})),this.U_()}j_(e){this.D_=e}q_(){return this.D_}Y_(){return this.bo.filter(Rw)}kl(){return this.bo}Gs(e){let t=e.Ft();return t===null||this.B_!==t&&this.A_!==t}h_(e,t,n){this.K_(e,t,n?e.ln():this.bo.length)}l_(e,t){let n=this.bo.indexOf(e);wS(n!==-1,`removeDataSource: invalid data source`),this.bo.splice(n,1),t||this.bo.forEach(((e,t)=>e._n(t)));let r=$(e.Ft()).pl();if(this.P_.has(r)){let t=TS(this.P_.get(r)),n=t.indexOf(e);n!==-1&&(t.splice(n,1),t.length===0&&this.P_.delete(r))}let i=e.Ft();i&&i.kl().indexOf(e)>=0&&(i.l_(e),this.G_(i)),this.Z_()}Xs(e){return e===this.B_?`left`:e===this.A_?`right`:`overlay`}X_(){return this.B_}J_(){return this.A_}Q_(e,t){e.u_(t)}tu(e,t){e.c_(t),this.U_()}iu(e){e.d_()}nu(e,t){e.f_(t)}su(e,t){e.p_(t),this.U_()}eu(e){e.v_()}U_(){this.bo.forEach((e=>{e.Nn()}))}kn(){let[e,t]=this.ru(),n=null;return e.N().visible&&e.kl().length!==0?n=e:t.N().visible&&t.kl().length!==0?n=t:this.bo.length!==0&&(n=this.bo[0].Ft()),n===null&&(n=this.Zs()??e),n}Zs(){let[e,t]=this.ru();return e.N().visible?e:t.N().visible?t:null}G_(e){e!==null&&e.zo()&&this.hu(e)}au(e){let t=this.ia.Ee();e.Ao({hs:!0}),t!==null&&e.b_(t),this.U_()}lu(){this.hu(this.B_),this.hu(this.A_)}ou(){this.G_(this.B_),this.G_(this.A_),this.bo.forEach((e=>{this.Gs(e)&&this.G_(e.Ft())})),this.U_(),this.sn.mr()}Dt(){return this.xo===null&&(this.xo=Nw(this.bo)),this.xo}_u(){let e=this.Dt(),t=this.sn.cu()?.uu,n=this.sn.N().hoveredSeriesOnTop,r=this.R_;if(r!==null&&r.Kh===e&&r.du===t&&r.fu===n)return r.pu;let i=function(e,t,n){if(!n)return e;let r=e.indexOf(t);if(r===-1||r===e.length-1)return e;let i=[];for(let t=0;t<e.length;t++)t!==r&&i.push(e[t]);return i.push(e[r]),i}(e,t,n);return this.R_={Kh:e,du:t,fu:n,pu:i},i}vu(e,t){t=gw(t,0,this.bo.length-1);let n=this.bo.indexOf(e);wS(n!==-1,`setSeriesOrder: invalid data source`),this.bo.splice(n,1),this.bo.splice(t,0,e),this.bo.forEach(((e,t)=>e._n(t))),this.Z_();for(let e of[this.B_,this.A_])e.a_(),e.vl();this.sn.mr()}Vt(){return this.Dt().filter(Rw)}mu(){return this.I_}wu(){return this.V_}ol(e){this.fa.push(new ew(e))}_l(e){this.fa=this.fa.filter((t=>t.Qh()!==e)),e.detached&&e.detached(),this.sn.mr()}Mu(){return this.fa}il(e,t){return this.fa.map((n=>n.Qs(e,t))).filter((e=>e!==null))}hu(e){let t=e.g_();if(t&&t.length>0&&!this.ia.Zi()){let t=this.ia.Ee();t!==null&&e.b_(t)}e.Nn()}K_(e,t,n){let r=this.O_(t);if(r===null&&(r=this.E_(t,this.sn.N().overlayPriceScales)),this.bo.splice(n,0,e),!uC(t)){let n=this.P_.get(t)||[];n.push(e),this.P_.set(t,n)}e._n(n),r.h_(e),e.un(r),this.G_(r),this.Z_()}Z_(){this.xo=null,this.R_=null}ru(){return this.sn.N().defaultVisiblePriceScaleId===`left`?[this.B_,this.A_]:[this.A_,this.B_]}L_(e,t,n){t._e!==n._e&&this.hu(e)}E_(e,t){let n=new Lw(e,{visible:!0,autoScale:!0,...NS(t)},this.sn.N().layout,this.sn.N().localization,this.sn.Xi());return n.$o(this.$t()),n}};function Bw(e,t){return t===null||e.se===2&&t.se!==2||(t.se!==2||e.se===2)&&e.ne!==t.ne&&e.ne<t.ne}function Vw(e){return{te:e.te,ie:e.ie}}function Hw(e){return{ne:e.distance??0,se:e.hitTestPriority??(e.itemType===`marker`?2:0),ee:e.itemType??`primitive`,gu:e.cursorStyle,te:e.externalId}}function Uw(e){return{uu:e.uu,bu:Vw(e.Su),gu:e.Su.gu,ee:e.Su.ee??`primitive`}}function Ww(e,t,n,r){let i=null;for(let a of e){let e=a.Qs?.(t,n,r)??null;if(e===null){let i=a.Tt(r);e=i!==null&&i.Qs?i.Qs(t,n):null}if(e!==null){let t={xu:a,Su:e};(i===null||Bw(t.Su,i.Su))&&(i=t)}}return i}function Gw(e){return e.jn!==void 0}function Kw(e,t,n){let r=[e,...e.Dt()].reverse(),i=function(e,t,n){let r,i,a;for(let c of e){let e=c.il?.(t,n)??[];for(let t of e){let e=Hw(t);o=t.zOrder,s=r?.zOrder,(!s||o===`top`&&s!==`top`||o===`normal`&&s===`bottom`||t.zOrder===r?.zOrder&&i!==void 0&&Bw(e,i)||t.zOrder===r?.zOrder&&i===void 0)&&(r=t,i=e,a=c)}}var o,s;return r&&a&&i?{Su:i,Cu:r,uu:a}:null}(r,t,n);if(i?.Cu.zOrder===`top`)return Uw(i);let a=null,o=null;for(let s of r){if(i&&i.uu===s&&i.Cu.zOrder!==`bottom`&&!i.Cu.isBackground)return a??Uw(i);if(Gw(s)){let r=Ww(s.jn(e),t,n,e);if(r!==null){let e={uu:s,xu:r.xu,bu:Vw(r.Su),gu:r.Su.gu,ee:r.Su.ee??`primitive`};(a===null||Bw(r.Su,o))&&(a=e,o=r.Su)}}if(i&&i.uu===s&&i.Cu.zOrder!==`bottom`&&i.Cu.isBackground)return a??Uw(i)}return a===null?i?.Cu?Uw(i):null:a}var qw=class{constructor(e,t,n=50){this.Vs=0,this.Bs=1,this.Es=1,this.Ls=new Map,this.As=new Map,this.yu=e,this.Pu=t,this.zs=n}ku(e){let t=e.time,n=this.Pu.cacheKey(t),r=this.Ls.get(n);if(r!==void 0)return r.Tu;if(this.Vs===this.zs){let e=this.As.get(this.Es);this.As.delete(this.Es),this.Ls.delete(TS(e)),this.Es++,this.Vs--}let i=this.yu(e);return this.Ls.set(n,{Tu:i,Ws:this.Bs}),this.As.set(this.Bs,n),this.Vs++,this.Bs++,i}},Jw=class{constructor(e,t){wS(e<=t,`right should be >= left`),this.Ru=e,this.Du=t}Na(){return this.Ru}bi(){return this.Du}Iu(){return this.Du-this.Ru+1}ze(e){return this.Ru<=e&&e<=this.Du}Ze(e){return this.Ru===e.Na()&&this.Du===e.bi()}};function Yw(e,t){return e===null||t===null?e===t:e.Ze(t)}var Xw=class{constructor(){this.Vu=new Map,this.Ls=null,this.Bu=!1}Eu(e){this.Bu=e,this.Ls=null}Au(e,t){this.Lu(t),this.Ls=null;for(let n=t;n<e.length;++n){let t=e[n],r=this.Vu.get(t.timeWeight);r===void 0&&(r=[],this.Vu.set(t.timeWeight,r)),r.push({index:n,time:t.time,weight:t.timeWeight,originalTime:t.originalTime})}}zu(e,t,n,r,i){let a=Math.ceil(t/e);return this.Ls!==null&&this.Ls.Ou===a&&i===this.Ls.Nu&&n===this.Ls.Fu||(this.Ls={Nu:i,Fu:n,zl:this.Wu(a,n,r),Ou:a}),this.Ls.zl}Lu(e){if(e===0)return void this.Vu.clear();let t=[];this.Vu.forEach(((n,r)=>{e<=n[0].index?t.push(r):n.splice(UC(n,e,(t=>t.index<e)),1/0)}));for(let e of t)this.Vu.delete(e)}Wu(e,t,n){let r=[],i=e=>!t||n.has(e.index);for(let t of Array.from(this.Vu.keys()).sort(((e,t)=>t-e))){if(!this.Vu.get(t))continue;let n=r;r=[];let a=n.length,o=0,s=TS(this.Vu.get(t)),c=s.length,l=1/0,u=-1/0;for(let t=0;t<c;t++){let c=s[t],d=c.index;for(;o<a;){let e=n[o],t=e.index;if(!(t<d&&i(e))){l=t;break}o++,r.push(e),u=t,l=1/0}if(l-d>=e&&d-u>=e&&i(c))r.push(c),u=d;else if(this.Bu)return n}for(;o<a;o++)i(n[o])&&r.push(n[o])}return r}},Zw=class e{constructor(e){this.Hu=e}Uu(){return this.Hu===null?null:new Jw(Math.floor(this.Hu.Na()),Math.ceil(this.Hu.bi()))}$u(){return this.Hu}static ju(){return new e(null)}};function Qw(e,t){return e.weight>t.weight?e:t}var $w=class{constructor(e,t,n,r){this.k_=0,this.qu=null,this.Yu=[],this.Po=null,this.yo=null,this.Ku=new Xw,this.Gu=new Map,this.Zu=Zw.ju(),this.Xu=!0,this.Ju=new DS,this.Qu=new DS,this.tc=new DS,this.nc=null,this.sc=null,this.ec=new Map,this.rc=-1,this.hc=[],this.ac=1,this.yn=t,this.Do=n,this.lc=t.rightOffset,this.oc=t.barSpacing,this.sn=e,this._c(t),this.Pu=r,this.uc(),this.Ku.Eu(t.uniformDistribution),this.cc(),this.dc()}N(){return this.yn}fc(e){OS(this.Do,e),this.vc(),this.uc()}vr(e,t){OS(this.yn,e),this.yn.fixLeftEdge&&this.mc(),this.yn.fixRightEdge&&this.wc(),e.barSpacing!==void 0&&this.sn.Ms(e.barSpacing),e.rightOffset!==void 0&&this.sn.gs(e.rightOffset),this._c(e),e.minBarSpacing===void 0&&e.maxBarSpacing===void 0||this.sn.Ms(e.barSpacing??this.oc),e.ignoreWhitespaceIndices!==void 0&&e.ignoreWhitespaceIndices!==this.yn.ignoreWhitespaceIndices&&this.dc(),this.vc(),this.uc(),e.enableConflation===void 0&&e.conflationThresholdFactor===void 0||this.cc(),this.tc.p()}Rn(e){return this.Yu[e]?.time??null}en(e){return this.Yu[e]??null}Mc(e,t){if(this.Yu.length<1)return null;if(this.Pu.key(e)>this.Pu.key(this.Yu[this.Yu.length-1].time))return t?this.Yu.length-1:null;let n=UC(this.Yu,this.Pu.key(e),((e,t)=>this.Pu.key(e.time)<t));return this.Pu.key(e)<this.Pu.key(this.Yu[n].time)?t?n:null:n}Zi(){return this.k_===0||this.Yu.length===0||this.qu===null}gc(){return this.Yu.length>0}Ee(){return this.bc(),this.Zu.Uu()}Sc(){return this.bc(),this.Zu.$u()}xc(){let e=this.Ee();if(e===null)return null;let t={from:e.Na(),to:e.bi()};return this.Cc(t)}Cc(e){let t=Math.round(e.from),n=Math.round(e.to),r=$(this.yc()),i=$(this.Pc());return{from:$(this.en(Math.max(r,t))),to:$(this.en(Math.min(i,n)))}}kc(e){return{from:$(this.Mc(e.from,!0)),to:$(this.Mc(e.to,!0))}}nn(){return this.k_}H_(e){if(!isFinite(e)||e<=0||this.k_===e)return;let t=this.Sc(),n=this.k_;if(this.k_=e,this.Xu=!0,this.yn.lockVisibleTimeRangeOnResize&&n!==0){let t=this.oc*e/n;this.oc=t}if(this.yn.fixLeftEdge&&t!==null&&t.Na()<=0){let t=n-e;this.lc-=Math.round(t/this.oc)+1,this.Xu=!0}this.Tc(),this.Rc()}jt(e){if(this.Zi()||!AS(e))return 0;let t=this.Dc()+this.lc-e;return this.k_-(t+.5)*this.oc-1}Ic(e,t){let n=this.Dc(),r=t===void 0?0:t.from,i=t===void 0?e.length:t.to;for(let t=r;t<i;t++){let r=e[t].wt,i=n+this.lc-r,a=this.k_-(i+.5)*this.oc-1;e[t]._t=a}}Vc(e,t){let n=Math.ceil(this.Bc(e));return t&&this.yn.ignoreWhitespaceIndices&&!this.Ec(n)?this.Ac(n):n}gs(e){this.Xu=!0,this.lc=e,this.Rc(),this.sn.Lc(),this.sn.mr()}ml(){return this.oc}Ms(e){let t=this.oc;if(this.zc(e),this.yn.rightOffsetPixels!==void 0&&t!==0){let e=this.lc*t/this.oc;this.lc=e}this.Rc(),this.sn.Lc(),this.sn.mr()}Oc(){return this.lc}zl(){if(this.Zi())return null;if(this.sc!==null)return this.sc;let e=this.oc,t=5*(this.sn.N().layout.fontSize+4)/8*(this.yn.tickMarkMaxCharacterLength||8),n=Math.round(t/e),r=$(this.Ee()),i=Math.max(r.Na(),r.Na()-n),a=Math.max(r.bi(),r.bi()-n),o=this.Ku.zu(e,t,this.yn.ignoreWhitespaceIndices,this.ec,this.rc),s=this.yc()+n,c=this.Pc()-n,l=this.Nc(),u=this.yn.fixLeftEdge||l,d=this.yn.fixRightEdge||l,f=0;for(let e of o){if(!(i<=e.index&&e.index<=a))continue;let n;f<this.hc.length?(n=this.hc[f],n.coord=this.jt(e.index),n.label=this.Fc(e),n.weight=e.weight):(n={needAlignCoordinate:!1,coord:this.jt(e.index),label:this.Fc(e),weight:e.weight},this.hc.push(n)),this.oc>t/2&&!l?n.needAlignCoordinate=!1:n.needAlignCoordinate=u&&e.index<=s||d&&e.index>=c,f++}return this.hc.length=f,this.sc=this.hc,this.hc}Wc(){let e;this.Xu=!0,this.Ms(this.yn.barSpacing),e=this.yn.rightOffsetPixels===void 0?this.yn.rightOffset:this.yn.rightOffsetPixels/this.ml(),this.gs(e)}Hc(e){this.Xu=!0,this.qu=e,this.Rc(),this.mc()}Uc(e,t){let n=this.Bc(e),r=this.ml(),i=r+r/10*t;this.Ms(i),this.yn.rightBarStaysOnScroll||this.gs(this.Oc()+(n-this.Bc(e)))}u_(e){this.Po&&this.v_(),this.yo===null&&this.nc===null&&(this.Zi()||(this.yo=e,this.$c()))}c_(e){if(this.nc===null)return;let t=gw(this.k_-e,0,this.k_),n=gw(this.k_-$(this.yo),0,this.k_);t!==0&&n!==0&&this.Ms(this.nc.ml*t/n)}d_(){this.yo!==null&&(this.yo=null,this.jc())}f_(e){this.Po===null&&this.nc===null&&(this.Zi()||(this.Po=e,this.$c()))}p_(e){if(this.Po===null)return;let t=(this.Po-e)/this.ml();this.lc=$(this.nc).Oc+t,this.Xu=!0,this.Rc()}v_(){this.Po!==null&&(this.Po=null,this.jc())}qc(){this.Yc(this.yn.rightOffset)}Yc(e,t=400){if(!isFinite(e))throw RangeError(`offset is required and must be finite number`);if(!isFinite(t)||t<=0)throw RangeError(`animationDuration (optional) must be finite positive number`);let n=this.lc,r=performance.now();this.sn.ps({Kc:e=>(e-r)/t>=1,Gc:i=>{let a=(i-r)/t;return a>=1?e:n+(e-n)*a}})}Pt(e,t){this.Xu=!0,this.Yu=e,this.Ku.Au(e,t),this.Rc()}Zc(){return this.Ju}Xc(){return this.Qu}Jc(){return this.tc}Dc(){return this.qu||0}Qc(e,t){let n=e.Iu(),r=t&&this.yn.rightOffsetPixels||0;this.zc((this.k_-r)/n),this.lc=e.bi()-this.Dc(),t&&(this.lc=r?r/this.ml():this.yn.rightOffset),this.Rc(),this.Xu=!0,this.sn.Lc(),this.sn.mr()}td(){let e=this.yc(),t=this.Pc();if(e===null||t===null)return;let n=!this.yn.rightOffsetPixels&&this.yn.rightOffset||0;this.Qc(new Jw(e,t+n),!0)}nd(e){let t=new Jw(e.from,e.to);this.Qc(t)}rn(e){return this.Do.timeFormatter===void 0?this.Pu.formatHorzItem(e.time):this.Do.timeFormatter(e.originalTime)}dc(){if(!this.yn.ignoreWhitespaceIndices)return;this.ec.clear();let e=this.sn.Jn();for(let t of e)for(let e of t.fl())this.ec.set(e,!0);this.rc++}sd(){return this.ac}Sl(){let e=1/(window.devicePixelRatio||1),t=this.yn.minBarSpacing;if(t>=e)return[1];let n=[1],r=2;for(;r<=512;)t<e/r&&n.push(r),r*=2;return n}Nc(){let e=this.sn.N().handleScroll,t=this.sn.N().handleScale;return!(e.horzTouchDrag||e.mouseWheel||e.pressedMouseMove||e.vertTouchDrag||t.axisDoubleClickReset.time||t.axisPressedMouseMove.time||t.mouseWheel||t.pinch)}yc(){return this.Yu.length===0?null:0}Pc(){return this.Yu.length===0?null:this.Yu.length-1}ed(e){return(this.k_-1-e)/this.oc}Bc(e){let t=this.ed(e),n=this.Dc()+this.lc-t;return Math.round(1e6*n)/1e6}zc(e){let t=this.oc;this.oc=e,this.Tc(),t!==this.oc&&(this.Xu=!0,this.rd(),this.cc())}bc(){if(!this.Xu)return;if(this.Xu=!1,this.Zi())return void this.hd(Zw.ju());let e=this.Dc(),t=this.k_/this.oc,n=this.lc+e,r=new Jw(n-t+1,n);this.hd(new Zw(r))}Tc(){let e=gw(this.oc,this.ad(),this.ld());this.oc!==e&&(this.oc=e,this.Xu=!0)}ld(){return this.yn.maxBarSpacing>0?this.yn.maxBarSpacing:.5*this.k_}ad(){return this.yn.fixLeftEdge&&this.yn.fixRightEdge&&this.Yu.length!==0?this.k_/this.Yu.length:this.yn.minBarSpacing}cc(){if(!this.yn.enableConflation)return void(this.ac=1);let e=1/(window.devicePixelRatio||1)*(this.yn.conflationThresholdFactor??1);if(this.oc>=e)return void(this.ac=1);let t=e/this.oc,n=2**Math.floor(Math.log2(t));this.ac=Math.min(n,512)}Rc(){let e=this.od();e!==null&&this.lc<e&&(this.lc=e,this.Xu=!0);let t=this._d();this.lc>t&&(this.lc=t,this.Xu=!0)}od(){let e=this.yc(),t=this.qu;return e===null||t===null?null:e-t-1+(this.yn.fixLeftEdge?this.k_/this.oc:Math.min(2,this.Yu.length))}_d(){return this.yn.fixRightEdge?0:this.k_/this.oc-Math.min(2,this.Yu.length)}$c(){this.nc={ml:this.ml(),Oc:this.Oc()}}jc(){this.nc=null}Fc(e){let t=this.Gu.get(e.weight);return t===void 0&&(t=new qw((e=>this.ud(e)),this.Pu),this.Gu.set(e.weight,t)),t.ku(e)}ud(e){return this.Pu.formatTickmark(e,this.Do)}hd(e){let t=this.Zu;this.Zu=e,Yw(t.Uu(),this.Zu.Uu())||this.Ju.p(),Yw(t.$u(),this.Zu.$u())||this.Qu.p(),this.rd()}rd(){this.sc=null}vc(){this.rd(),this.Gu.clear()}uc(){this.Pu.updateFormatter(this.Do)}mc(){if(!this.yn.fixLeftEdge)return;let e=this.yc();if(e===null)return;let t=this.Ee();if(t===null)return;let n=t.Na()-e;if(n<0){let e=this.lc-n-1;this.gs(e)}this.Tc()}wc(){this.Rc(),this.Tc()}Ec(e){return!this.yn.ignoreWhitespaceIndices||this.ec.get(e)||!1}Ac(e){let t=function*(e){let t=Math.round(e),n=t<e,r=1;for(;;)n?(yield t+r,yield t-r):(yield t-r,yield t+r),r++}(e),n=this.Pc();for(;n;){let e=t.next().value;if(this.ec.get(e))return e;if(e<0||e>n)break}return e}_c(e){if(e.rightOffsetPixels!==void 0){let t=e.rightOffsetPixels/(e.barSpacing||this.oc);this.sn.gs(t)}}},eT,tT,nT,rT,iT;(function(e){e[e.OnTouchEnd=0]=`OnTouchEnd`,e[e.OnNextTap=1]=`OnNextTap`})(eT||={});var aT=class{constructor(e,t,n){this.dd=[],this.fd=[],this.pd=null,this.k_=0,this.vd=null,this.md=new DS,this.wd=new DS,this.Md=null,this.gd=e,this.yn=t,this.Pu=n,this.Io=new VS(this.yn.layout.colorParsers),this.bd=new RS(this),this.ia=new $w(this,t.timeScale,this.yn.localization,n),this.Ct=new lC(this,t.crosshair),this.Sd=new hw(t.crosshair),t.addDefaultPane&&(this.xd(0),this.dd[0].W_(2)),this.Cd=this.yd(0),this.Pd=this.yd(1)}ka(){this.kd(dC.ys())}mr(){this.kd(dC.Cs())}Ya(){this.kd(new dC(1))}Ta(e){let t=this.Td(e);this.kd(t)}cu(){return this.vd}Rd(e){if(this.vd?.uu===e?.uu&&this.vd?.bu?.te===e?.bu?.te&&this.vd?.bu?.ie===e?.bu?.ie&&this.vd?.gu===e?.gu&&this.vd?.ee===e?.ee)return;let t=this.vd;this.vd=e,t!==null&&this.Ta(t.uu),e!==null&&e.uu!==t?.uu&&this.Ta(e.uu)}N(){return this.yn}vr(e){OS(this.yn,e),this.dd.forEach((t=>t.z_(e))),e.timeScale!==void 0&&this.ia.vr(e.timeScale),e.localization!==void 0&&this.ia.fc(e.localization),(e.leftPriceScale||e.rightPriceScale)&&this.md.p(),this.Cd=this.yd(0),this.Pd=this.yd(1),this.ka()}Dd(e,t,n=0){let r=this.dd[n];if(r===void 0)return;if(e===`left`)return OS(this.yn,{leftPriceScale:t}),r.z_({leftPriceScale:t}),this.md.p(),void this.ka();if(e===`right`)return OS(this.yn,{rightPriceScale:t}),r.z_({rightPriceScale:t}),this.md.p(),void this.ka();let i=this.Id(e,n);i!==null&&(i.Ft.vr(t),this.md.p())}Id(e,t){let n=this.dd[t];if(n===void 0)return null;let r=n.O_(e);return r===null?null:{Kn:n,Ft:r}}Et(){return this.ia}Gn(){return this.dd}Vd(){return this.Ct}Bd(){return this.wd}Ed(e,t){e.$o(t),this.Lc()}H_(e){this.k_=e,this.ia.H_(this.k_),this.dd.forEach((t=>t.H_(e))),this.Lc()}Ad(e){this.dd.length!==1&&(wS(e>=0&&e<this.dd.length,`Invalid pane index`),this.dd.splice(e,1),this.ka())}Ld(e,t){if(this.dd.length<2)return;wS(e>=0&&e<this.dd.length,`Invalid pane index`);let n=this.dd[e],r=this.dd.reduce(((e,t)=>e+t.F_()),0),i=this.dd.reduce(((e,t)=>e+t.$t()),0),a=i-30*(this.dd.length-1);t=Math.min(a,Math.max(30,t));let o=r/i,s=n.$t();n.W_(t*o);let c=t-s,l=this.dd.length-1;for(let e of this.dd)if(e!==n){let t=Math.min(a,Math.max(30,e.$t()-c/l));c-=e.$t()-t,--l;let n=t*o;e.W_(n)}this.ka()}zd(e,t){wS(e>=0&&e<this.dd.length&&t>=0&&t<this.dd.length,`Invalid pane index`);let n=this.dd[e],r=this.dd[t];this.dd[e]=r,this.dd[t]=n,this.ka()}Od(e,t){if(wS(e>=0&&e<this.dd.length&&t>=0&&t<this.dd.length,`Invalid pane index`),e===t)return;let[n]=this.dd.splice(e,1);this.dd.splice(t,0,n),this.ka()}Q_(e,t,n){e.Q_(t,n)}tu(e,t,n){e.tu(t,n),this.Ra(),this.kd(this.Nd(e,2))}iu(e,t){e.iu(t),this.kd(this.Nd(e,2))}nu(e,t,n){t.zo()||e.nu(t,n)}su(e,t,n){t.zo()||(e.su(t,n),this.Ra(),this.kd(this.Nd(e,2)))}eu(e,t){t.zo()||(e.eu(t),this.kd(this.Nd(e,2)))}au(e,t){e.au(t),this.kd(this.Nd(e,2))}Fd(e){this.ia.u_(e)}Wd(e,t){let n=this.Et();if(n.Zi()||t===0)return;let r=n.nn();e=Math.max(1,Math.min(e,r)),n.Uc(e,t),this.Lc()}Hd(e){this.Ud(0),this.$d(e),this.jd()}qd(e){this.ia.c_(e),this.Lc()}Yd(){this.ia.d_(),this.mr()}Ud(e){this.ia.f_(e)}$d(e){this.ia.p_(e),this.Lc()}jd(){this.ia.v_(),this.mr()}Jn(){return this.fd}Wn(){return this.pd===null&&(this.pd=this.fd.filter((e=>e.It()))),this.pd}Pa(){this.pd=null}Kd(e,t,n,r,i){this.Ct.In(e,t);let a=NaN,o=this.ia.Vc(e,!0),s=this.ia.Ee();s!==null&&(o=Math.min(Math.max(s.Na(),o),s.bi())),o=this.Ct.Fn(o);let c=r.kn(),l=c.Lt();if(l!==null&&(a=c.Tn(t,l)),a=this.Sd.Pl(a,o,r),this.Ct.An(o,a,r),this.Ya(),!i){let i=Kw(r,e,t);this.Rd(i&&{uu:i.uu,bu:i.bu,gu:i.gu||null,ee:i.ee}),this.wd.p(this.Ct.Bt(),{x:e,y:t},n)}}Gd(e,t,n){let r=n.kn(),i=r.Lt(),a=r.Nt(e,$(i)),o=this.ia.Mc(t,!0),s=this.ia.jt($(o));this.Kd(s,a,null,n,!0)}Zd(e){this.Vd().zn(),this.Ya(),e||this.wd.p(null,null,null)}Ra(){let e=this.Ct.Kn();if(e!==null){let t=this.Ct.Bn(),n=this.Ct.En();this.Kd(t,n,null,e)}this.Ct.Nn()}Xd(e,t,n){let r=this.ia.Rn(0);t!==void 0&&n!==void 0&&this.ia.Pt(t,n);let i=this.ia.Rn(0),a=this.ia.Dc(),o=this.ia.Ee();if(o!==null&&r!==null&&i!==null){let t=o.ze(a),s=this.Pu.key(r)>this.Pu.key(i),c=e!==null&&e>a&&!s,l=this.ia.N().allowShiftVisibleRangeOnWhitespaceReplacement,u=t&&(n!==void 0||l)&&this.ia.N().shiftVisibleRangeOnNewBar;if(c&&!u){let t=e-a;this.ia.gs(this.ia.Oc()-t)}}this.ia.Hc(e)}Ba(e){e!==null&&e.ou()}Ks(e){if(function(e){return e instanceof zw}(e))return e;let t=this.dd.find((t=>t.Dt().includes(e)));return t===void 0?null:t}Lc(){this.dd.forEach((e=>e.ou())),this.Ra()}m(){this.dd.forEach((e=>e.m())),this.dd.length=0,this.yn.localization.priceFormatter=void 0,this.yn.localization.percentageFormatter=void 0,this.yn.localization.timeFormatter=void 0}Jd(){return this.bd}Js(){return this.bd.N()}N_(){return this.md}Qd(e,t){let n=this.xd(t);this.tf(e,n),this.fd.push(e),this.Pa(),this.fd.length===1?this.ka():this.mr()}if(e){let t=this.Ks(e),n=this.fd.indexOf(e);wS(n!==-1,`Series not found`);let r=$(t);this.fd.splice(n,1),r.l_(e),e.m&&e.m(),this.Pa(),this.ia.dc(),this.nf(r)}ya(e,t){let n=$(this.Ks(e));n.l_(e,!0),n.h_(e,t,!0)}td(){let e=dC.Cs();e.us(),this.kd(e)}sf(e){let t=dC.Cs();t.fs(e),this.kd(t)}ws(){let e=dC.Cs();e.ws(),this.kd(e)}Ms(e){let t=dC.Cs();t.Ms(e),this.kd(t)}gs(e){let t=dC.Cs();t.gs(e),this.kd(t)}ps(e){let t=dC.Cs();t.ps(e),this.kd(t)}cs(){let e=dC.Cs();e.cs(),this.kd(e)}ef(){let e=this.yn.defaultVisiblePriceScaleId,t=this.yn.leftPriceScale.visible;return t===this.yn.rightPriceScale.visible?e:t?`left`:`right`}rf(e,t){if(wS(t>=0,`Index should be greater or equal to 0`),t===this.hf(e))return;let n=$(this.Ks(e));n.l_(e);let r=this.xd(t);this.tf(e,r);let i=!1;n.kl().length===0&&(i=this.nf(n)),i||this.ka()}af(){return this.Pd}$(){return this.Cd}Ut(e){let t=this.Pd,n=this.Cd;if(t===n)return t;if(e=Math.max(0,Math.min(100,Math.round(100*e))),this.Md===null||this.Md.ah!==n||this.Md.oh!==t)this.Md={ah:n,oh:t,lf:new Map};else{let t=this.Md.lf.get(e);if(t!==void 0)return t}let r=this.Io.tt(n,t,e/100);return this.Md.lf.set(e,r),r}_f(e){return this.dd.indexOf(e)}Xi(){return this.Io}uf(){return this.cf()}cf(e){let t=new zw(this.ia,this);this.dd.push(t);let n=e??this.dd.length-1,r=dC.ys();return r.es(n,{rs:0,hs:!0}),this.kd(r),t}xd(e){return wS(e>=0,`Index should be greater or equal to 0`),(e=Math.min(this.dd.length,e))<this.dd.length?this.dd[e]:this.cf(e)}hf(e){return this.dd.findIndex((t=>t.Y_().includes(e)))}Nd(e,t){let n=new dC(t);if(e!==null){let r=this.dd.indexOf(e);n.es(r,{rs:t})}return n}Td(e,t){return t===void 0&&(t=2),this.Nd(this.Ks(e),t)}kd(e){this.gd&&this.gd(e),this.dd.forEach((e=>e.wu().wr().Pt()))}tf(e,t){let n=e.N().priceScaleId,r=n===void 0?this.ef():n;t.h_(e,r),uC(r)||e.vr(e.N())}yd(e){let t=this.yn.layout;return t.background.type===`gradient`?e===0?t.background.topColor:t.background.bottomColor:t.background.color}nf(e){return!e.q_()&&e.kl().length===0&&this.dd.length>1&&(this.dd.splice(this._f(e),1),this.ka(),!0)}};function oT(e){if(e>=1)return 0;let t=0;for(;t<8;t++){if(Math.abs(Math.round(e)-e)<1e-8)return t;e*=10}return t}function sT(e){return!kS(e)&&!jS(e)}function cT(e){return kS(e)}(function(e){e[e.Disabled=0]=`Disabled`,e[e.Continuous=1]=`Continuous`,e[e.OnDataUpdate=2]=`OnDataUpdate`})(tT||={}),function(e){e[e.LastBar=0]=`LastBar`,e[e.LastVisible=1]=`LastVisible`}(nT||={}),function(e){e.Solid=`solid`,e.VerticalGradient=`gradient`}(rT||={}),function(e){e[e.Year=0]=`Year`,e[e.Month=1]=`Month`,e[e.DayOfMonth=2]=`DayOfMonth`,e[e.Time=3]=`Time`,e[e.TimeWithSeconds=4]=`TimeWithSeconds`}(iT||={});var lT=e=>e.getUTCFullYear();function uT(e,t,n){return t.replace(/yyyy/g,(e=>mC(lT(e),4))(e)).replace(/yy/g,(e=>mC(lT(e)%100,2))(e)).replace(/MMMM/g,((e,t)=>new Date(e.getUTCFullYear(),e.getUTCMonth(),1).toLocaleString(t,{month:`long`}))(e,n)).replace(/MMM/g,((e,t)=>new Date(e.getUTCFullYear(),e.getUTCMonth(),1).toLocaleString(t,{month:`short`}))(e,n)).replace(/MM/g,(e=>mC((e=>e.getUTCMonth()+1)(e),2))(e)).replace(/dd/g,(e=>mC((e=>e.getUTCDate())(e),2))(e))}var dT=class{constructor(e=`yyyy-MM-dd`,t=`default`){this.df=e,this.ff=t}ku(e){return uT(e,this.df,this.ff)}},fT=class{constructor(e){this.pf=e||`%h:%m:%s`}ku(e){return this.pf.replace(`%h`,mC(e.getUTCHours(),2)).replace(`%m`,mC(e.getUTCMinutes(),2)).replace(`%s`,mC(e.getUTCSeconds(),2))}},pT={vf:`yyyy-MM-dd`,mf:`%h:%m:%s`,wf:` `,Mf:`default`},mT=class{constructor(e={}){let t={...pT,...e};this.gf=new dT(t.vf,t.Mf),this.bf=new fT(t.mf),this.Sf=t.wf}ku(e){return`${this.gf.ku(e)}${this.Sf}${this.bf.ku(e)}`}};function hT(e){return 60*e*60*1e3}function gT(e){return 60*e*1e3}var _T=[{xf:(vT=1,1e3*vT),Cf:10},{xf:gT(1),Cf:20},{xf:gT(5),Cf:21},{xf:gT(30),Cf:22},{xf:hT(1),Cf:30},{xf:hT(3),Cf:31},{xf:hT(6),Cf:32},{xf:hT(12),Cf:33}],vT;function yT(e,t){if(e.getUTCFullYear()!==t.getUTCFullYear())return 70;if(e.getUTCMonth()!==t.getUTCMonth())return 60;if(e.getUTCDate()!==t.getUTCDate())return 50;for(let n=_T.length-1;n>=0;--n)if(Math.floor(t.getTime()/_T[n].xf)!==Math.floor(e.getTime()/_T[n].xf))return _T[n].Cf;return 0}function bT(e){let t=e;if(jS(e)&&(t=ST(e)),!sT(t))throw Error(`time must be of type BusinessDay`);let n=new Date(Date.UTC(t.year,t.month-1,t.day,0,0,0,0));return{yf:Math.round(n.getTime()/1e3),Pf:t}}function xT(e){if(!cT(e))throw Error(`time must be of type isUTCTimestamp`);return{yf:e}}function ST(e){let t=new Date(e);if(isNaN(t.getTime()))throw Error(`Invalid date string=${e}, expected format=yyyy-mm-dd`);return{day:t.getUTCDate(),month:t.getUTCMonth()+1,year:t.getUTCFullYear()}}function CT(e){jS(e.time)&&(e.time=ST(e.time))}var wT=class{options(){return this.yn}setOptions(e){this.yn=e,this.updateFormatter(e.localization)}preprocessData(e){Array.isArray(e)?function(e){e.forEach(CT)}(e):CT(e)}createConverterToInternalObj(e){return $(function(e){return e.length===0?null:sT(e[0].time)||jS(e[0].time)?bT:xT}(e))}key(e){return typeof e==`object`&&`yf`in e?e.yf:this.key(this.convertHorzItemToInternal(e))}cacheKey(e){let t=e;return t.Pf===void 0?new Date(1e3*t.yf).getTime():new Date(Date.UTC(t.Pf.year,t.Pf.month-1,t.Pf.day)).getTime()}convertHorzItemToInternal(e){return cT(t=e)?xT(t):sT(t)?bT(t):bT(ST(t));var t}updateFormatter(e){if(!this.yn)return;let t=e.dateFormat;this.kf=this.yn.timeScale.timeVisible?new mT({vf:t,mf:this.yn.timeScale.secondsVisible?`%h:%m:%s`:`%h:%m`,wf:` `,Mf:e.locale}):new dT(t,e.locale)}formatHorzItem(e){let t=e;return this.kf.ku(new Date(1e3*t.yf))}formatTickmark(e,t){let n=function(e,t,n){switch(e){case 0:case 10:return t?n?4:3:2;case 20:case 21:case 22:case 30:case 31:case 32:case 33:return t?3:2;case 50:return 2;case 60:return 1;case 70:return 0}}(e.weight,this.yn.timeScale.timeVisible,this.yn.timeScale.secondsVisible),r=this.yn.timeScale;if(r.tickMarkFormatter!==void 0){let i=r.tickMarkFormatter(e.originalTime,n,t.locale);if(i!==null)return i}return function(e,t,n){let r={};switch(t){case 0:r.year=`numeric`;break;case 1:r.month=`short`;break;case 2:r.day=`numeric`;break;case 3:r.hour12=!1,r.hour=`2-digit`,r.minute=`2-digit`;break;case 4:r.hour12=!1,r.hour=`2-digit`,r.minute=`2-digit`,r.second=`2-digit`}let i=e.Pf===void 0?new Date(1e3*e.yf):new Date(Date.UTC(e.Pf.year,e.Pf.month-1,e.Pf.day));return new Date(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate(),i.getUTCHours(),i.getUTCMinutes(),i.getUTCSeconds(),i.getUTCMilliseconds()).toLocaleString(n,r)}(e.time,n,t.locale)}maxTickMarkWeight(e){let t=e.reduce(Qw,e[0]).weight;return t>30&&t<50&&(t=30),t}fillWeightsForPoints(e,t){(function(e,t=0){if(e.length===0)return;let n=t===0?null:e[t-1].time.yf,r=n===null?null:new Date(1e3*n),i=0;for(let a=t;a<e.length;++a){let t=e[a],o=new Date(1e3*t.time.yf);r!==null&&(t.timeWeight=yT(o,r)),i+=t.time.yf-(n||t.time.yf),n=t.time.yf,r=o}if(t===0&&e.length>1){let t=Math.ceil(i/(e.length-1)),n=new Date(1e3*(e[0].time.yf-t));e[0].timeWeight=yT(new Date(1e3*e[0].time.yf),n)}})(e,t)}static Tf(e){return OS({localization:{dateFormat:`dd MMM 'yy`}},e??{})}},TT=typeof window<`u`;function ET(){return!!TT&&window.navigator.userAgent.toLowerCase().indexOf(`firefox`)>-1}function DT(){return!!TT&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function OT(e,t){switch(e){case`custom`:return t===void 0?`series`:`custom-object`;case`price-line`:return`custom-price-line`;case`marker`:return`series-marker`;case`primitive`:return`primitive`;default:return`series`}}function kT(e){return e+e%2}function AT(e){TT&&window.chrome!==void 0&&e.addEventListener(`mousedown`,(e=>{if(e.button===1)return e.preventDefault(),!1}))}var jT=class{constructor(e,t,n){this.Rf=0,this.Df=null,this.If={_t:-1/0,ut:1/0},this.Vf=0,this.Bf=null,this.Ef={_t:-1/0,ut:1/0},this.Af=null,this.Lf=!1,this.zf=null,this.Of=null,this.Nf=!1,this.Ff=!1,this.Wf=!1,this.Hf=null,this.Uf=null,this.$f=null,this.jf=null,this.qf=null,this.Yf=null,this.Kf=null,this.Gf=0,this.Zf=!1,this.Xf=!1,this.Jf=!1,this.Qf=0,this.tp=null,this.ip=!DT(),this.np=e=>{this.sp(e)},this.ep=e=>{if(this.rp(e)){let t=this.hp(e);if(++this.Vf,this.Bf&&this.Vf>1){let{ap:n}=this.lp(PT(e),this.Ef);n<30&&!this.Wf&&this.op(t,this.up._p),this.cp()}}else{let t=this.hp(e);if(++this.Rf,this.Df&&this.Rf>1){let{ap:n}=this.lp(PT(e),this.If);n<5&&!this.Ff&&this.dp(t,this.up.fp),this.pp()}}},this.vp=e,this.up=t,this.yn=n,this.mp()}m(){this.Hf!==null&&(this.Hf(),this.Hf=null),this.Uf!==null&&(this.Uf(),this.Uf=null),this.jf!==null&&(this.jf(),this.jf=null),this.qf!==null&&(this.qf(),this.qf=null),this.Yf!==null&&(this.Yf(),this.Yf=null),this.$f!==null&&(this.$f(),this.$f=null),this.wp(),this.pp()}Mp(e){this.jf&&this.jf();let t=this.gp.bind(this);if(this.jf=()=>{this.vp.removeEventListener(`mousemove`,t)},this.vp.addEventListener(`mousemove`,t),this.rp(e))return;let n=this.hp(e);this.dp(n,this.up.bp),this.ip=!0}pp(){this.Df!==null&&clearTimeout(this.Df),this.Rf=0,this.Df=null,this.If={_t:-1/0,ut:1/0}}cp(){this.Bf!==null&&clearTimeout(this.Bf),this.Vf=0,this.Bf=null,this.Ef={_t:-1/0,ut:1/0}}gp(e){if(this.Jf||this.Of!==null||this.rp(e))return;let t=this.hp(e);this.dp(t,this.up.Sp),this.ip=!0}xp(e){let t=IT(e.changedTouches,$(this.tp));if(t===null||(this.Qf=FT(e),this.Kf!==null)||this.Xf)return;this.Zf=!0;let{Cp:n,yp:r,ap:i}=this.lp(PT(t),$(this.Of));if(this.Nf||!(i<5)){if(!this.Nf){let e=.5*n,t=r>=e&&!this.yn.Pp(),i=e>r&&!this.yn.kp();t||i||(this.Xf=!0),this.Nf=!0,this.Wf=!0,this.wp(),this.cp()}if(!this.Xf){let n=this.hp(e,t);this.op(n,this.up.Tp),NT(e)}}}Rp(e){if(e.button!==0)return;let{ap:t}=this.lp(PT(e),$(this.zf));if(t>=5&&(this.Ff=!0,this.pp()),this.Ff){let t=this.hp(e);this.dp(t,this.up.Dp)}}lp(e,t){let n=Math.abs(t._t-e._t),r=Math.abs(t.ut-e.ut);return{Cp:n,yp:r,ap:n+r}}Ip(e){let t=IT(e.changedTouches,$(this.tp));if(t===null&&e.touches.length===0&&(t=e.changedTouches[0]),t===null)return;this.tp=null,this.Qf=FT(e),this.wp(),this.Of=null,this.Yf&&=(this.Yf(),null);let n=this.hp(e,t);if(this.op(n,this.up.Vp),++this.Vf,this.Bf&&this.Vf>1){let{ap:e}=this.lp(PT(t),this.Ef);e<30&&!this.Wf&&this.op(n,this.up._p),this.cp()}else this.Wf||(this.op(n,this.up.Bp),this.up.Bp&&NT(e));this.Vf===0&&NT(e),e.touches.length===0&&this.Lf&&(this.Lf=!1,NT(e))}sp(e){if(e.button!==0)return;let t=this.hp(e);if(this.zf=null,this.Jf=!1,this.qf&&=(this.qf(),null),ET()&&this.vp.ownerDocument.documentElement.removeEventListener(`mouseleave`,this.np),!this.rp(e)){if(this.dp(t,this.up.Ep),++this.Rf,this.Df&&this.Rf>1){let{ap:n}=this.lp(PT(e),this.If);n<5&&!this.Ff&&this.dp(t,this.up.fp),this.pp()}else this.Ff||this.dp(t,this.up.Ap)}}wp(){this.Af!==null&&(clearTimeout(this.Af),this.Af=null)}Lp(e){if(this.tp!==null)return;let t=e.changedTouches[0];this.tp=t.identifier,this.Qf=FT(e);let n=this.vp.ownerDocument.documentElement;this.Wf=!1,this.Nf=!1,this.Xf=!1,this.Of=PT(t),this.Yf&&=(this.Yf(),null);{let t=this.xp.bind(this),r=this.Ip.bind(this);this.Yf=()=>{n.removeEventListener(`touchmove`,t),n.removeEventListener(`touchend`,r)},n.addEventListener(`touchmove`,t,{passive:!1}),n.addEventListener(`touchend`,r,{passive:!1}),this.wp(),this.Af=setTimeout(this.zp.bind(this,e),240)}let r=this.hp(e,t);this.op(r,this.up.Op),this.Bf||(this.Vf=0,this.Bf=setTimeout(this.cp.bind(this),500),this.Ef=PT(t))}Np(e){if(e.button!==0)return;let t=this.vp.ownerDocument.documentElement;ET()&&t.addEventListener(`mouseleave`,this.np),this.Ff=!1,this.zf=PT(e),this.qf&&=(this.qf(),null);{let e=this.Rp.bind(this),n=this.sp.bind(this);this.qf=()=>{t.removeEventListener(`mousemove`,e),t.removeEventListener(`mouseup`,n)},t.addEventListener(`mousemove`,e),t.addEventListener(`mouseup`,n)}if(this.Jf=!0,this.rp(e))return;let n=this.hp(e);this.dp(n,this.up.Fp),this.Df||(this.Rf=0,this.Df=setTimeout(this.pp.bind(this),500),this.If=PT(e))}mp(){this.vp.addEventListener(`mouseenter`,this.Mp.bind(this)),this.vp.addEventListener(`touchcancel`,this.wp.bind(this));{let e=this.vp.ownerDocument,t=e=>{this.up.Wp&&(e.composed&&this.vp.contains(e.composedPath()[0])||e.target&&this.vp.contains(e.target)||this.up.Wp())};this.Uf=()=>{e.removeEventListener(`touchstart`,t)},this.Hf=()=>{e.removeEventListener(`mousedown`,t)},e.addEventListener(`mousedown`,t),e.addEventListener(`touchstart`,t,{passive:!0})}DT()&&(this.$f=()=>{this.vp.removeEventListener(`dblclick`,this.ep)},this.vp.addEventListener(`dblclick`,this.ep)),this.vp.addEventListener(`mouseleave`,this.Hp.bind(this)),this.vp.addEventListener(`touchstart`,this.Lp.bind(this),{passive:!0}),AT(this.vp),this.vp.addEventListener(`mousedown`,this.Np.bind(this)),this.Up(),this.vp.addEventListener(`touchmove`,(()=>{}),{passive:!1})}Up(){this.up.$p===void 0&&this.up.jp===void 0&&this.up.qp===void 0||(this.vp.addEventListener(`touchstart`,(e=>this.Yp(e.touches)),{passive:!0}),this.vp.addEventListener(`touchmove`,(e=>{if(e.touches.length===2&&this.Kf!==null&&this.up.jp!==void 0){let t=MT(e.touches[0],e.touches[1])/this.Gf;this.up.jp(this.Kf,t),NT(e)}}),{passive:!1}),this.vp.addEventListener(`touchend`,(e=>{this.Yp(e.touches)})))}Yp(e){e.length===1&&(this.Zf=!1),e.length!==2||this.Zf||this.Lf?this.Kp():this.Gp(e)}Gp(e){let t=this.vp.getBoundingClientRect()||{left:0,top:0};this.Kf={_t:(e[0].clientX-t.left+(e[1].clientX-t.left))/2,ut:(e[0].clientY-t.top+(e[1].clientY-t.top))/2},this.Gf=MT(e[0],e[1]),this.up.$p!==void 0&&this.up.$p(),this.wp()}Kp(){this.Kf!==null&&(this.Kf=null,this.up.qp!==void 0&&this.up.qp())}Hp(e){if(this.jf&&this.jf(),this.rp(e)||!this.ip)return;let t=this.hp(e);this.dp(t,this.up.Zp),this.ip=!DT()}zp(e){let t=IT(e.touches,$(this.tp));if(t===null)return;let n=this.hp(e,t);this.op(n,this.up.Xp),this.Wf=!0,this.Lf=!0}rp(e){return e.sourceCapabilities&&e.sourceCapabilities.firesTouchEvents!==void 0?e.sourceCapabilities.firesTouchEvents:FT(e)<this.Qf+500}op(e,t){t&&t.call(this.up,e)}dp(e,t){t&&t.call(this.up,e)}hp(e,t){let n=t||e,r=this.vp.getBoundingClientRect()||{left:0,top:0};return{clientX:n.clientX,clientY:n.clientY,pageX:n.pageX,pageY:n.pageY,screenX:n.screenX,screenY:n.screenY,localX:n.clientX-r.left,localY:n.clientY-r.top,ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,Jp:!e.type.startsWith(`mouse`)&&e.type!==`contextmenu`&&e.type!==`click`,Qp:e.type,tv:n.target,xu:e.view,iv:()=>{e.type!==`touchstart`&&NT(e)}}}};function MT(e,t){let n=e.clientX-t.clientX,r=e.clientY-t.clientY;return Math.sqrt(n*n+r*r)}function NT(e){e.cancelable&&e.preventDefault()}function PT(e){return{_t:e.pageX,ut:e.pageY}}function FT(e){return e.timeStamp||performance.now()}function IT(e,t){for(let n=0;n<e.length;++n)if(e[n].identifier===t)return e[n];return null}var LT=class{constructor(e,t,n){this.nv=null,this.sv=null,this.ev=!0,this.rv=null,this.hv=e,this.av=e.lv()[t],this.ov=e.lv()[n],this._v=document.createElement(`tr`),this._v.style.height=`1px`,this.uv=document.createElement(`td`),this.uv.style.position=`relative`,this.uv.style.padding=`0`,this.uv.style.margin=`0`,this.uv.setAttribute(`colspan`,`3`),this.cv(),this._v.appendChild(this.uv),this.ev=this.hv.N().layout.panes.enableResize,this.ev?this.dv():(this.nv=null,this.sv=null)}m(){this.sv!==null&&this.sv.m()}fv(){return this._v}pv(){return Q({width:this.av.pv().width,height:1})}vv(){return Q({width:this.av.vv().width,height:1*window.devicePixelRatio})}mv(e,t,n){let r=this.vv();e.fillStyle=this.hv.N().layout.panes.separatorColor,e.fillRect(t,n,r.width,r.height)}Pt(){this.cv(),this.hv.N().layout.panes.enableResize!==this.ev&&(this.ev=this.hv.N().layout.panes.enableResize,this.ev?this.dv():(this.nv!==null&&(this.uv.removeChild(this.nv.wv),this.uv.removeChild(this.nv.Mv),this.nv=null),this.sv!==null&&(this.sv.m(),this.sv=null)))}dv(){let e=document.createElement(`div`),t=e.style;t.position=`fixed`,t.display=`none`,t.zIndex=`49`,t.top=`0`,t.left=`0`,t.width=`100%`,t.height=`100%`,t.cursor=`row-resize`,this.uv.appendChild(e);let n=document.createElement(`div`),r=n.style;r.position=`absolute`,r.zIndex=`50`,r.top=`-4px`,r.height=`9px`,r.width=`100%`,r.backgroundColor=``,r.cursor=`row-resize`,this.uv.appendChild(n);let i={bp:this.gv.bind(this),Zp:this.bv.bind(this),Fp:this.Sv.bind(this),Op:this.Sv.bind(this),Dp:this.xv.bind(this),Tp:this.xv.bind(this),Ep:this.Cv.bind(this),Vp:this.Cv.bind(this)};this.sv=new jT(n,i,{Pp:()=>!1,kp:()=>!0}),this.nv={Mv:n,wv:e}}cv(){this.uv.style.background=this.hv.N().layout.panes.separatorColor}gv(e){this.nv!==null&&(this.nv.Mv.style.backgroundColor=this.hv.N().layout.panes.separatorHoverColor)}bv(e){this.nv!==null&&this.rv===null&&(this.nv.Mv.style.backgroundColor=``)}Sv(e){if(this.nv===null)return;let t=this.av.yv().F_()+this.ov.yv().F_(),n=t/(this.av.pv().height+this.ov.pv().height),r=30*n;t<=2*r||(this.rv={Pv:e.pageY,kv:this.av.yv().F_(),Tv:t-r,Rv:t,Dv:n,Iv:r},this.nv.wv.style.display=`block`)}xv(e){let t=this.rv;if(t===null)return;let n=(e.pageY-t.Pv)*t.Dv,r=gw(t.kv+n,t.Iv,t.Tv);this.av.yv().W_(r),this.ov.yv().W_(t.Rv-r),this.hv.Qt().ka()}Cv(e){this.rv!==null&&this.nv!==null&&(this.rv=null,this.nv.wv.style.display=`none`)}};function RT(e,t){return e.Vv-t.Vv}function zT(e,t,n){let r=(e.Vv-t.Vv)/(e.wt-t.wt);return Math.sign(r)*Math.min(Math.abs(r),n)}var BT=class{constructor(e,t,n,r){this.Bv=null,this.Ev=null,this.Av=null,this.Lv=null,this.zv=null,this.Ov=0,this.Nv=0,this.Fv=e,this.Wv=t,this.Hv=n,this.Ps=r}Uv(e,t){if(this.Bv!==null){if(this.Bv.wt===t)return void(this.Bv.Vv=e);if(Math.abs(this.Bv.Vv-e)<this.Ps)return}this.Lv=this.Av,this.Av=this.Ev,this.Ev=this.Bv,this.Bv={wt:t,Vv:e}}me(e,t){if(this.Bv===null||this.Ev===null||t-this.Bv.wt>50)return;let n=0,r=zT(this.Bv,this.Ev,this.Wv),i=RT(this.Bv,this.Ev),a=[r],o=[i];if(n+=i,this.Av!==null){let e=zT(this.Ev,this.Av,this.Wv);if(Math.sign(e)===Math.sign(r)){let t=RT(this.Ev,this.Av);if(a.push(e),o.push(t),n+=t,this.Lv!==null){let e=zT(this.Av,this.Lv,this.Wv);if(Math.sign(e)===Math.sign(r)){let t=RT(this.Av,this.Lv);a.push(e),o.push(t),n+=t}}}}let s=0;for(let e=0;e<a.length;++e)s+=o[e]/n*a[e];Math.abs(s)<this.Fv||(this.zv={Vv:e,wt:t},this.Nv=s,this.Ov=function(e,t){let n=Math.log(t);return Math.log(1*n/-e)/n}(Math.abs(s),this.Hv))}Gc(e){let t=$(this.zv),n=e-t.wt;return t.Vv+this.Nv*(this.Hv**+n-1)/Math.log(this.Hv)}Kc(e){return this.zv===null||this.$v(e)===this.Ov}$v(e){let t=e-$(this.zv).wt;return Math.min(t,this.Ov)}},VT=class{constructor(e,t){this.jv=void 0,this.qv=void 0,this.Yv=void 0,this.vn=!1,this.Kv=e,this.Gv=t,this.Zv()}Pt(){this.Zv()}Xv(){this.jv&&this.Kv.removeChild(this.jv),this.qv&&this.Kv.removeChild(this.qv),this.jv=void 0,this.qv=void 0}Jv(){return this.vn!==this.Qv()||this.Yv!==this.tm()}tm(){return this.Gv.Qt().Xi().J(this.Gv.N().layout.textColor)>160?`dark`:`light`}Qv(){return this.Gv.N().layout.attributionLogo}im(){let e=new URL(location.href);return e.hostname?`&utm_source=`+e.hostname+e.pathname:``}Zv(){this.Jv()&&(this.Xv(),this.vn=this.Qv(),this.vn&&(this.Yv=this.tm(),this.qv=document.createElement(`style`),this.qv.innerText=`a#tv-attr-logo{--fill:#131722;--stroke:#fff;position:absolute;left:10px;bottom:10px;height:19px;width:35px;margin:0;padding:0;border:0;z-index:3;}a#tv-attr-logo[data-dark]{--fill:#D1D4DC;--stroke:#131722;}`,this.jv=document.createElement(`a`),this.jv.href=`https://www.tradingview.com/?utm_medium=lwc-link&utm_campaign=lwc-chart${this.im()}`,this.jv.title=`Charting by TradingView`,this.jv.id=`tv-attr-logo`,this.jv.target=`_blank`,this.jv.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="35" height="19" fill="none"><g fill-rule="evenodd" clip-path="url(#a)" clip-rule="evenodd"><path fill="var(--stroke)" d="M2 0H0v10h6v9h21.4l.5-1.3 6-15 1-2.7H23.7l-.5 1.3-.2.6a5 5 0 0 0-7-.9V0H2Zm20 17h4l5.2-13 .8-2h-7l-1 2.5-.2.5-1.5 3.8-.3.7V17Zm-.8-10a3 3 0 0 0 .7-2.7A3 3 0 1 0 16.8 7h4.4ZM14 7V2H2v6h6v9h4V7h2Z"/><path fill="var(--fill)" d="M14 2H2v6h6v9h6V2Zm12 15h-7l6-15h7l-6 15Zm-7-9a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"/></g><defs><clipPath id="a"><path fill="var(--stroke)" d="M0 0h35v19H0z"/></clipPath></defs></svg>`,this.jv.toggleAttribute(`data-dark`,this.Yv===`dark`),this.Kv.appendChild(this.qv),this.Kv.appendChild(this.jv)))}};function HT(e,t){let n=$(e.ownerDocument).createElement(`canvas`);e.appendChild(n);let r=pS(n,{type:`device-pixel-content-box`,options:{allowResizeObserver:!0},transform:(e,t)=>({width:Math.max(e.width,t.width),height:Math.max(e.height,t.height)})});return r.resizeCanvasElement(t),r}function UT(e){e.width=1,e.height=1,e.getContext(`2d`)?.clearRect(0,0,1,1)}function WT(e,t,n,r){e.qh&&e.qh(t,n,r)}function GT(e,t,n,r){e.st(t,n,r)}function KT(e,t,n,r){qT(e(n,r),t,r)}function qT(e,t,n){for(let r of e){let e=r.Tt(n);e!==null&&t(e)}}function JT(e,t){return n=>function(e){return e.Ft!==void 0}(n)&&(n.Ft()?.pl()??``)===t?n.Qa?.(e)??[]:[]}function YT(e,t,n,r){if(!e.length)return;let i=0,a=e[0].$t(r,!0),o=t===1?n/2-(e[0].Hi()-a/2):e[0].Hi()-a/2-n/2;o=Math.max(0,o);for(let a=1;a<e.length;a++){let s=e[a],c=e[a-1],l=c.$t(r,!1),u=s.Hi(),d=c.Hi();if(t===1?u>d-l:u<d+l){let r=d-l*t;s.Ui(r);let a=r-t*l/2;if((t===1?a<0:a>n)&&o>0){let r=t===1?-1-a:a-n,s=Math.min(r,o);for(let n=i;n<e.length;n++)e[n].Ui(e[n].Hi()+t*s);o-=s}}else i=a,o=t===1?d-l-u:u-(d+l)}}var XT=class{constructor(e,t,n,r){this.Ki=null,this.nm=null,this.sm=!1,this.rm=new yC(200),this.hm=null,this.am=0,this.lm=!1,this.om=()=>{this.lm||this.yt._m().Qt().mr()},this.um=()=>{this.lm||this.yt._m().Qt().mr()},this.yt=e,this.yn=t,this.Ro=t.layout,this.bd=n,this.dm=r===`left`,this.fm=JT(`normal`,r),this.pm=JT(`top`,r),this.vm=JT(`bottom`,r),this.uv=document.createElement(`div`),this.uv.style.height=`100%`,this.uv.style.overflow=`hidden`,this.uv.style.width=`25px`,this.uv.style.left=`0`,this.uv.style.position=`relative`,this.wm=HT(this.uv,Q({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om);let i=this.wm.canvasElement;i.style.position=`absolute`,i.style.zIndex=`1`,i.style.left=`0`,i.style.top=`0`,this.Mm=HT(this.uv,Q({width:16,height:16})),this.Mm.subscribeSuggestedBitmapSizeChanged(this.um);let a=this.Mm.canvasElement;a.style.position=`absolute`,a.style.zIndex=`2`,a.style.left=`0`,a.style.top=`0`;let o={Fp:this.Sv.bind(this),Op:this.Sv.bind(this),Dp:this.xv.bind(this),Tp:this.xv.bind(this),Wp:this.gm.bind(this),Ep:this.Cv.bind(this),Vp:this.Cv.bind(this),fp:this.bm.bind(this),_p:this.bm.bind(this),bp:this.Sm.bind(this),Zp:this.bv.bind(this)};this.sv=new jT(this.Mm.canvasElement,o,{Pp:()=>!this.yn.handleScroll.vertTouchDrag,kp:()=>!0})}m(){this.sv.m(),this.Mm.unsubscribeSuggestedBitmapSizeChanged(this.um),UT(this.Mm.canvasElement),this.Mm.dispose(),this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),UT(this.wm.canvasElement),this.wm.dispose(),this.Ki!==null&&this.Ki.__().u(this),this.Ki=null}fv(){return this.uv}P(){return this.Ro.fontSize}xm(){let e=this.bd.N();return this.hm!==e.k&&(this.rm.Os(),this.hm=e.k),e}Cm(){if(this.Ki===null)return 0;let e=0,t=this.xm(),n=$(this.wm.canvasElement.getContext(`2d`,{colorSpace:this.yt._m().N().layout.colorSpace}));n.save();let r=this.Ki.zl();n.font=this.ym(),r.length>0&&(e=Math.max(this.rm.Ii(n,r[0].eo),this.rm.Ii(n,r[r.length-1].eo)));let i=this.Pm();for(let t=i.length;t--;){let r=this.rm.Ii(n,i[t].ri());r>e&&(e=r)}let a=this.Ki.Lt();if(a!==null&&this.nm!==null&&(o=this.yn.crosshair).mode!==2&&o.horzLine.visible&&o.horzLine.labelVisible){let t=this.Ki.Tn(1,a),r=this.Ki.Tn(this.nm.height-2,a);e=Math.max(e,this.rm.Ii(n,this.Ki.Ji(Math.floor(Math.min(t,r))+.11111111111111,a)),this.rm.Ii(n,this.Ki.Ji(Math.ceil(Math.max(t,r))-.11111111111111,a)))}var o;n.restore();let s=e||34;return kT(Math.ceil(t.S+t.C+t.V+t.B+5+s))}km(e){this.nm!==null&&lS(this.nm,e)||(this.nm=e,this.lm=!0,this.wm.resizeCanvasElement(e),this.Mm.resizeCanvasElement(e),this.lm=!1,this.uv.style.width=`${e.width}px`,this.uv.style.height=`${e.height}px`)}Tm(){return $(this.nm).width}un(e){this.Ki!==e&&(this.Ki!==null&&this.Ki.__().u(this),this.Ki=e,e.__().i(this.wo.bind(this),this))}Ft(){return this.Ki}Os(){let e=this.yt.yv();this.yt._m().Qt().au(e,$(this.Ft()))}Rm(e){if(this.nm===null)return;let t={colorSpace:this.yt._m().N().layout.colorSpace};if(e!==1){this.Dm(),this.wm.applySuggestedBitmapSize();let e=vS(this.wm,t);e!==null&&(e.useBitmapCoordinateSpace((e=>{this.Im(e),this.Vm(e)})),this.yt.Bm(e,this.vm),this.Em(e),this.yt.Bm(e,this.fm),this.Am(e))}this.Mm.applySuggestedBitmapSize();let n=vS(this.Mm,t);n!==null&&(n.useBitmapCoordinateSpace((({context:e,bitmapSize:t})=>{e.clearRect(0,0,t.width,t.height)})),this.Lm(n),this.yt.Bm(n,this.pm))}vv(){return this.wm.bitmapSize}mv(e,t,n,r){let i=this.vv();if(i.width>0&&i.height>0&&(e.drawImage(this.wm.canvasElement,t,n),r)){let r=this.Mm.canvasElement;e.drawImage(r,t,n)}}Pt(){this.Ki?.zl()}Sv(e){if(this.Ki===null||this.Ki.Zi()||!this.yn.handleScale.axisPressedMouseMove.price)return;let t=this.yt._m().Qt(),n=this.yt.yv();this.sm=!0,t.Q_(n,this.Ki,e.localY)}xv(e){if(this.Ki===null||!this.yn.handleScale.axisPressedMouseMove.price)return;let t=this.yt._m().Qt(),n=this.yt.yv(),r=this.Ki;t.tu(n,r,e.localY)}gm(){if(this.Ki===null||!this.yn.handleScale.axisPressedMouseMove.price)return;let e=this.yt._m().Qt(),t=this.yt.yv(),n=this.Ki;this.sm&&(this.sm=!1,e.iu(t,n))}Cv(e){if(this.Ki===null||!this.yn.handleScale.axisPressedMouseMove.price)return;let t=this.yt._m().Qt(),n=this.yt.yv();this.sm=!1,t.iu(n,this.Ki)}bm(e){this.yn.handleScale.axisDoubleClickReset.price&&this.Os()}Sm(e){this.Ki!==null&&(!this.yt._m().Qt().N().handleScale.axisPressedMouseMove.price||this.Ki.je()||this.Ki.No()||this.zm(1))}bv(e){this.zm(0)}Pm(){let e=[],t=this.Ki===null?void 0:this.Ki;return(n=>{for(let r=0;r<n.length;++r){let i=n[r].qn(this.yt.yv(),t);for(let t=0;t<i.length;t++)e.push(i[t])}})(this.yt.yv().Dt()),e}Im({context:e,bitmapSize:t}){let{width:n,height:r}=t,i=this.yt.yv().Qt(),a=i.$(),o=i.af();a===o?ZS(e,0,0,n,r,a):eC(e,0,0,n,r,a,o)}Vm({context:e,bitmapSize:t,horizontalPixelRatio:n}){if(this.nm===null||this.Ki===null||!this.Ki.N().borderVisible)return;e.fillStyle=this.Ki.N().borderColor;let r=Math.max(1,Math.floor(this.xm().S*n)),i;i=this.dm?t.width-r:0,e.fillRect(i,0,r,t.height)}Em(e){if(this.nm===null||this.Ki===null)return;let t=this.Ki.zl(),n=this.Ki.N(),r=this.xm(),i=this.dm?this.nm.width-r.C:0;n.borderVisible&&n.ticksVisible&&e.useBitmapCoordinateSpace((({context:e,horizontalPixelRatio:a,verticalPixelRatio:o})=>{e.fillStyle=n.borderColor;let s=Math.max(1,Math.floor(o)),c=Math.floor(.5*o),l=Math.round(r.C*a);e.beginPath();for(let n of t)e.rect(Math.floor(i*a),Math.round(n.Vl*o)-c,l,s);e.fill()})),e.useMediaCoordinateSpace((({context:e})=>{e.font=this.ym(),e.fillStyle=n.textColor??this.Ro.textColor,e.textAlign=this.dm?`right`:`left`,e.textBaseline=`middle`;let a=this.dm?Math.round(i-r.V):Math.round(i+r.C+r.V),o=t.map((t=>this.rm.Di(e,t.eo)));for(let n=t.length;n--;){let r=t[n];e.fillText(r.eo,a,r.Vl+o[n])}}))}Dm(){if(this.nm===null||this.Ki===null)return;let e=this.nm.height/2,t=[],n=this.Ki.Dt().slice(),r=this.yt.yv(),i=this.xm();this.Ki===r.Zs()&&this.yt.yv().Dt().forEach((e=>{r.Gs(e)&&n.push(e)}));let a=this.Ki.kl()[0],o=this.Ki;n.forEach((n=>{let i=n.qn(r,o);i.forEach((e=>{e.$i()&&e.Wi()===null&&(e.Ui(null),t.push(e))})),a===n&&i.length>0&&(e=i[0].Ei())})),this.Ki.N().alignLabels&&this.Om(t,i,e)}Om(e,t,n){if(this.nm===null)return;let r=e.filter((e=>e.Ei()<=n)),i=e.filter((e=>e.Ei()>n));r.sort(((e,t)=>t.Ei()-e.Ei())),r.length&&i.length&&i.push(r[0]),i.sort(((e,t)=>e.Ei()-t.Ei()));for(let n of e){let e=Math.floor(n.$t(t)/2),r=n.Ei();r>-e&&r<e&&n.Ui(e),r>this.nm.height-e&&r<this.nm.height+e&&n.Ui(this.nm.height-e)}YT(r,1,this.nm.height,t),YT(i,-1,this.nm.height,t)}Am(e){if(this.nm===null)return;let t=this.Pm(),n=this.xm(),r=this.dm?`right`:`left`;t.forEach((t=>{t.ji()&&t.Tt($(this.Ki)).st(e,n,this.rm,r)}))}Lm(e){if(this.nm===null||this.Ki===null)return;let t=this.yt._m().Qt(),n=[],r=this.yt.yv(),i=t.Vd().qn(r,this.Ki);i.length&&n.push(i);let a=this.xm(),o=this.dm?`right`:`left`;n.forEach((t=>{t.forEach((t=>{t.Tt($(this.Ki)).st(e,a,this.rm,o)}))}))}zm(e){this.uv.style.cursor=e===1?`ns-resize`:`default`}wo(){let e=this.Cm();this.am<e&&this.yt._m().Qt().ka(),this.am=e}ym(){return LS(this.Ro.fontSize,this.Ro.fontFamily)}};function ZT(e,t){return e.Xa?.(t)??[]}function QT(e,t){return e.jn?.(t)??[]}function $T(e,t){return e.cn?.(t)??[]}function eE(e,t){return e.qa?.(t)??[]}var tE=class e{constructor(e,t){this.nm=Q({width:0,height:0}),this.Nm=null,this.Fm=null,this.Wm=null,this.Hm=null,this.Um=!1,this.$m=new DS,this.jm=new DS,this.qm=0,this.Ym=!1,this.Km=null,this.Gm=!1,this.Zm=null,this.Xm=null,this.lm=!1,this.om=()=>{this.lm||this.Jm===null||this.sn().mr()},this.um=()=>{this.lm||this.Jm===null||this.sn().mr()},this.Gv=e,this.Jm=t,this.Jm.mu().i(this.Qm.bind(this),this,!0),this.tw=document.createElement(`td`),this.tw.style.padding=`0`,this.tw.style.position=`relative`;let n=document.createElement(`div`);n.style.width=`100%`,n.style.height=`100%`,n.style.position=`relative`,n.style.overflow=`hidden`,this.iw=document.createElement(`td`),this.iw.style.padding=`0`,this.nw=document.createElement(`td`),this.nw.style.padding=`0`,this.tw.appendChild(n),this.wm=HT(n,Q({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om);let r=this.wm.canvasElement;r.style.position=`absolute`,r.style.zIndex=`1`,r.style.left=`0`,r.style.top=`0`,this.Mm=HT(n,Q({width:16,height:16})),this.Mm.subscribeSuggestedBitmapSizeChanged(this.um);let i=this.Mm.canvasElement;i.style.position=`absolute`,i.style.zIndex=`2`,i.style.left=`0`,i.style.top=`0`,this._v=document.createElement(`tr`),this._v.appendChild(this.iw),this._v.appendChild(this.tw),this._v.appendChild(this.nw),this.sw(),this.sv=new jT(this.Mm.canvasElement,this,{Pp:()=>this.Km===null&&!this.Gv.N().handleScroll.vertTouchDrag,kp:()=>this.Km===null&&!this.Gv.N().handleScroll.horzTouchDrag})}m(){this.Nm!==null&&this.Nm.m(),this.Fm!==null&&this.Fm.m(),this.Wm=null,this.Mm.unsubscribeSuggestedBitmapSizeChanged(this.um),UT(this.Mm.canvasElement),this.Mm.dispose(),this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),UT(this.wm.canvasElement),this.wm.dispose(),this.Jm!==null&&(this.Jm.mu().u(this),this.Jm.m()),this.sv.m()}yv(){return $(this.Jm)}ew(t){this.Jm!==null&&this.Jm.mu().u(this),this.Jm=t,this.Jm!==null&&this.Jm.mu().i(e.prototype.Qm.bind(this),this,!0),this.sw(),this.Gv.lv().indexOf(this)===this.Gv.lv().length-1?(this.Wm=this.Wm??new VT(this.tw,this.Gv),this.Wm.Pt()):(this.Wm?.Xv(),this.Wm=null)}_m(){return this.Gv}fv(){return this._v}sw(){if(this.Jm!==null&&(this.rw(),this.sn().Jn().length!==0)){if(this.Nm!==null){let e=this.Jm.X_();this.Nm.un($(e))}if(this.Fm!==null){let e=this.Jm.J_();this.Fm.un($(e))}}}hw(){this.Nm!==null&&this.Nm.Pt(),this.Fm!==null&&this.Fm.Pt()}F_(){return this.Jm===null?0:this.Jm.F_()}W_(e){this.Jm&&this.Jm.W_(e)}bp(e){if(!this.Jm)return;this.aw();let t=e.localX,n=e.localY;this.lw(t,n,e)}Fp(e){this.aw(),this.ow(),this.lw(e.localX,e.localY,e)}Sp(e){if(!this.Jm)return;this.aw();let t=e.localX,n=e.localY;this.lw(t,n,e)}Ap(e){this.Jm!==null&&(this.aw(),this.lw(e.localX,e.localY,e),this._w(e))}fp(e){this.Jm!==null&&this.uw(this.jm,e)}_p(e){this.fp(e)}Dp(e){this.aw(),this.cw(e),this.lw(e.localX,e.localY,e)}Ep(e){this.Jm!==null&&(this.aw(),this.Ym=!1,this.dw(e))}Bp(e){this.Jm!==null&&this._w(e)}Xp(e){if(this.Ym=!0,this.Km===null){let t={x:e.localX,y:e.localY};this.fw(t,t,e)}}Zp(e){this.Jm!==null&&(this.aw(),this.Jm.Qt().Rd(null),this.pw())}mw(){return this.$m}ww(){return this.jm}$p(){this.qm=1,this.sn().cs()}jp(e,t){if(!this.Gv.N().handleScale.pinch)return;let n=5*(t-this.qm);this.qm=t,this.sn().Wd(e._t,n)}Op(e){this.Ym=!1,this.Gm=this.Km!==null,this.ow();let t=this.sn().Vd();this.Km!==null&&t.It()&&(this.Zm={x:t.ni(),y:t.si()},this.Km={x:e.localX,y:e.localY})}Tp(e){if(this.Jm===null)return;let t=e.localX,n=e.localY;if(this.Km===null)this.cw(e);else{this.Gm=!1;let r=$(this.Zm),i=r.x+(t-this.Km.x),a=r.y+(n-this.Km.y);this.lw(i,a,e)}}Vp(e){this._m().N().trackingMode.exitMode===0&&(this.Gm=!0),this.Mw(),this.dw(e)}Qs(e,t){let n=this.Jm;return n===null?null:Kw(n,e,t)}gw(e,t){$(t===`left`?this.Nm:this.Fm).km(Q({width:e,height:this.nm.height}))}pv(){return this.nm}km(e){lS(this.nm,e)||(this.nm=e,this.lm=!0,this.wm.resizeCanvasElement(e),this.Mm.resizeCanvasElement(e),this.lm=!1,this.tw.style.width=e.width+`px`,this.tw.style.height=e.height+`px`)}bw(){let e=$(this.Jm);e.G_(e.X_()),e.G_(e.J_());for(let t of e.kl())if(e.Gs(t)){let n=t.Ft();n!==null&&e.G_(n),t.Nn()}for(let t of e.Mu())t.Nn()}vv(){return this.wm.bitmapSize}mv(e,t,n,r){let i=this.vv();if(i.width>0&&i.height>0&&(e.drawImage(this.wm.canvasElement,t,n),r)){let r=this.Mm.canvasElement;e!==null&&e.drawImage(r,t,n)}}Rm(e){if(e===0||this.Jm===null)return;e>1&&this.bw(),this.Nm!==null&&this.Nm.Rm(e),this.Fm!==null&&this.Fm.Rm(e);let t={colorSpace:this.Gv.N().layout.colorSpace};if(e!==1){this.wm.applySuggestedBitmapSize();let e=vS(this.wm,t);e!==null&&(e.useBitmapCoordinateSpace((e=>{this.Im(e)})),this.Jm&&(this.Sw(e,ZT),this.xw(e),this.Sw(e,QT),this.Sw(e,$T)))}this.Mm.applySuggestedBitmapSize();let n=vS(this.Mm,t);n!==null&&(n.useBitmapCoordinateSpace((({context:e,bitmapSize:t})=>{e.clearRect(0,0,t.width,t.height)})),this.Cw(n),this.Sw(n,eE),this.Sw(n,$T))}yw(){return this.Nm}Pw(){return this.Fm}Bm(e,t){this.Sw(e,t)}Qm(){this.Jm!==null&&this.Jm.mu().u(this),this.Jm=null}_w(e){this.uw(this.$m,e)}uw(e,t){let n=t.localX,r=t.localY;e.v()&&e.p(this.sn().Et().Vc(n),{x:n,y:r},t)}Im({context:e,bitmapSize:t}){let{width:n,height:r}=t,i=this.sn(),a=i.$(),o=i.af();a===o?ZS(e,0,0,n,r,o):eC(e,0,0,n,r,a,o)}xw(e){let t=$(this.Jm),n=t.wu().wr().Tt(t);n!==null&&n.st(e,!1)}Cw(e){this.kw(e,QT,GT,this.sn().Vd())}Sw(e,t){let n=$(this.Jm),r=t===QT?this.Tw():null,i=r===null?null:this.Rw(r,n),a=n.Mu();if(i===null||r===null){let r=n._u();this.Dw(e,t,WT,a,r),this.Dw(e,t,GT,a,r);return}let o=n.Dt(),s=e=>e===r?i.Za:void 0;this.Dw(e,t,WT,a,o,s),this.Dw(e,t,GT,a,o,s),this.kw(e,t,WT,r,i.qa),this.kw(e,t,GT,r,i.qa)}Dw(e,t,n,r,i,a){for(let i of r)this.kw(e,t,n,i);if(a!==void 0)for(let r of i)this.kw(e,t,n,r,a(r));else for(let r of i)this.kw(e,t,n,r)}Tw(){let e=$(this.Jm),t=e.Qt().cu()?.uu;if(!e.Qt().N().hoveredSeriesOnTop||t===void 0)return null;for(let n of e.Dt())if(n===t)return n;return null}Rw(e,t){let n=e.Ga?.(t)??null;return n===null||n.qa.length===0?null:n}kw(e,t,n,r,i){let a=$(this.Jm),o=a.Qt().cu(),s=o!==null&&o.uu===r,c=o!==null&&s&&o.bu!==void 0?o.bu.ie:void 0,l=t=>n(t,e,s,c);i===void 0?KT(t,l,r,a):qT(i,l,a)}rw(){if(this.Jm===null)return;let e=this.Gv,t=this.Jm.X_().N().visible,n=this.Jm.J_().N().visible;t||this.Nm===null||(this.iw.removeChild(this.Nm.fv()),this.Nm.m(),this.Nm=null),n||this.Fm===null||(this.nw.removeChild(this.Fm.fv()),this.Fm.m(),this.Fm=null);let r=e.Qt().Jd();t&&this.Nm===null&&(this.Nm=new XT(this,e.N(),r,`left`),this.iw.appendChild(this.Nm.fv())),n&&this.Fm===null&&(this.Fm=new XT(this,e.N(),r,`right`),this.nw.appendChild(this.Fm.fv()))}Iw(e){return e.Jp&&this.Ym||this.Km!==null}lw(e,t,n){e=Math.max(0,Math.min(e,this.nm.width-1)),t=Math.max(0,Math.min(t,this.nm.height-1)),this.sn().Kd(e,t,n,$(this.Jm))}pw(){this.sn().Zd()}Mw(){this.Gm&&(this.Km=null,this.pw())}fw(e,t,n){this.Km=e,this.Gm=!1,this.lw(t.x,t.y,n);let r=this.sn().Vd();this.Zm={x:r.ni(),y:r.si()}}sn(){return this.Gv.Qt()}dw(e){if(!this.Um)return;let t=this.sn(),n=this.yv();if(t.eu(n,n.kn()),this.Hm=null,this.Um=!1,t.jd(),this.Xm!==null){let e=performance.now(),n=t.Et();this.Xm.me(n.Oc(),e),this.Xm.Kc(e)||t.ps(this.Xm)}}aw(){this.Km=null}ow(){if(this.Jm){if(this.sn().cs(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)$(document.activeElement).blur();else{let e=document.getSelection();e!==null&&e.removeAllRanges()}!this.Jm.kn().Zi()&&this.sn().Et().Zi()}}cw(e){if(this.Jm===null)return;let t=this.sn(),n=t.Et();if(n.Zi())return;let r=this.Gv.N(),i=r.handleScroll,a=r.kineticScroll;if((!i.pressedMouseMove||e.Jp)&&(!i.horzTouchDrag&&!i.vertTouchDrag||!e.Jp))return;let o=this.Jm.kn(),s=performance.now();if(this.Hm!==null||this.Iw(e)||(this.Hm={x:e.clientX,y:e.clientY,yf:s,Vw:e.localX,Bw:e.localY}),this.Hm!==null&&!this.Um&&(this.Hm.x!==e.clientX||this.Hm.y!==e.clientY)){if(e.Jp&&a.touch||!e.Jp&&a.mouse){let e=n.ml();this.Xm=new BT(.2/e,7/e,.997,15/e),this.Xm.Uv(n.Oc(),this.Hm.yf)}else this.Xm=null;o.Zi()||t.nu(this.Jm,o,e.localY),t.Ud(e.localX),this.Um=!0}this.Um&&(o.Zi()||t.su(this.Jm,o,e.localY),t.$d(e.localX),this.Xm!==null&&this.Xm.Uv(n.Oc(),s))}},nE=class{constructor(e,t,n,r,i){this.xt=!0,this.nm=Q({width:0,height:0}),this.om=()=>this.Rm(3),this.dm=e===`left`,this.bd=n.Jd,this.yn=t,this.Ew=r,this.Aw=i,this.uv=document.createElement(`div`),this.uv.style.width=`25px`,this.uv.style.height=`100%`,this.uv.style.overflow=`hidden`,this.wm=HT(this.uv,Q({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om)}m(){this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),UT(this.wm.canvasElement),this.wm.dispose()}fv(){return this.uv}pv(){return this.nm}km(e){lS(this.nm,e)||(this.nm=e,this.wm.resizeCanvasElement(e),this.uv.style.width=`${e.width}px`,this.uv.style.height=`${e.height}px`,this.xt=!0)}Rm(e){if(e<3&&!this.xt||this.nm.width===0||this.nm.height===0)return;this.xt=!1,this.wm.applySuggestedBitmapSize();let t=vS(this.wm,{colorSpace:this.yn.layout.colorSpace});t!==null&&t.useBitmapCoordinateSpace((e=>{this.Im(e),this.Vm(e)}))}vv(){return this.wm.bitmapSize}mv(e,t,n){let r=this.vv();r.width>0&&r.height>0&&e.drawImage(this.wm.canvasElement,t,n)}Vm({context:e,bitmapSize:t,horizontalPixelRatio:n,verticalPixelRatio:r}){if(!this.Ew())return;e.fillStyle=this.yn.timeScale.borderColor;let i=Math.floor(this.bd.N().S*n),a=Math.floor(this.bd.N().S*r),o=this.dm?t.width-i:0;e.fillRect(o,0,i,a)}Im({context:e,bitmapSize:t}){ZS(e,0,0,t.width,t.height,this.Aw())}};function rE(e){return t=>t.tl?.(e)??[]}var iE=rE(`normal`),aE=rE(`top`),oE=rE(`bottom`),sE=class{constructor(e,t){this.Lw=null,this.zw=null,this.M=null,this.Ow=!1,this.nm=Q({width:0,height:0}),this.Nw=new DS,this.rm=new yC(5),this.lm=!1,this.om=()=>{this.lm||this.Gv.Qt().mr()},this.um=()=>{this.lm||this.Gv.Qt().mr()},this.Gv=e,this.Pu=t,this.yn=e.N().layout,this.jv=document.createElement(`tr`),this.Fw=document.createElement(`td`),this.Fw.style.padding=`0`,this.Ww=document.createElement(`td`),this.Ww.style.padding=`0`,this.uv=document.createElement(`td`),this.uv.style.height=`25px`,this.uv.style.padding=`0`,this.Hw=document.createElement(`div`),this.Hw.style.width=`100%`,this.Hw.style.height=`100%`,this.Hw.style.position=`relative`,this.Hw.style.overflow=`hidden`,this.uv.appendChild(this.Hw),this.wm=HT(this.Hw,Q({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om);let n=this.wm.canvasElement;n.style.position=`absolute`,n.style.zIndex=`1`,n.style.left=`0`,n.style.top=`0`,this.Mm=HT(this.Hw,Q({width:16,height:16})),this.Mm.subscribeSuggestedBitmapSizeChanged(this.um);let r=this.Mm.canvasElement;r.style.position=`absolute`,r.style.zIndex=`2`,r.style.left=`0`,r.style.top=`0`,this.jv.appendChild(this.Fw),this.jv.appendChild(this.uv),this.jv.appendChild(this.Ww),this.Uw(),this.Gv.Qt().N_().i(this.Uw.bind(this),this),this.sv=new jT(this.Mm.canvasElement,this,{Pp:()=>!0,kp:()=>!this.Gv.N().handleScroll.horzTouchDrag})}m(){this.sv.m(),this.Lw!==null&&this.Lw.m(),this.zw!==null&&this.zw.m(),this.Mm.unsubscribeSuggestedBitmapSizeChanged(this.um),UT(this.Mm.canvasElement),this.Mm.dispose(),this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),UT(this.wm.canvasElement),this.wm.dispose()}fv(){return this.jv}$w(){return this.Lw}jw(){return this.zw}Fp(e){if(this.Ow)return;this.Ow=!0;let t=this.Gv.Qt();!t.Et().Zi()&&this.Gv.N().handleScale.axisPressedMouseMove.time&&t.Fd(e.localX)}Op(e){this.Fp(e)}Wp(){let e=this.Gv.Qt();!e.Et().Zi()&&this.Ow&&(this.Ow=!1,this.Gv.N().handleScale.axisPressedMouseMove.time&&e.Yd())}Dp(e){let t=this.Gv.Qt();!t.Et().Zi()&&this.Gv.N().handleScale.axisPressedMouseMove.time&&t.qd(e.localX)}Tp(e){this.Dp(e)}Ep(){this.Ow=!1;let e=this.Gv.Qt();e.Et().Zi()&&!this.Gv.N().handleScale.axisPressedMouseMove.time||e.Yd()}Vp(){this.Ep()}fp(){this.Gv.N().handleScale.axisDoubleClickReset.time&&this.Gv.Qt().ws()}_p(){this.fp()}bp(){this.Gv.Qt().N().handleScale.axisPressedMouseMove.time&&this.zm(1)}Zp(){this.zm(0)}pv(){return this.nm}qw(){return this.Nw}Yw(e,t,n){lS(this.nm,e)||(this.nm=e,this.lm=!0,this.wm.resizeCanvasElement(e),this.Mm.resizeCanvasElement(e),this.lm=!1,this.uv.style.width=`${e.width}px`,this.uv.style.height=`${e.height}px`,this.Nw.p(e)),this.Lw!==null&&this.Lw.km(Q({width:t,height:e.height})),this.zw!==null&&this.zw.km(Q({width:n,height:e.height}))}Kw(){let e=this.Gw();return Math.ceil(e.S+e.C+e.P+e.A+e.I+e.Zw)}Pt(){this.Gv.Qt().Et().zl()}vv(){return this.wm.bitmapSize}mv(e,t,n,r){let i=this.vv();if(i.width>0&&i.height>0&&(e.drawImage(this.wm.canvasElement,t,n),r)){let r=this.Mm.canvasElement;e.drawImage(r,t,n)}}Rm(e){if(e===0)return;let t={colorSpace:this.yn.colorSpace};if(e!==1){this.wm.applySuggestedBitmapSize();let n=vS(this.wm,t);n!==null&&(n.useBitmapCoordinateSpace((e=>{this.Im(e),this.Vm(e),this.Xw(n,oE)})),this.Em(n),this.Xw(n,iE)),this.Lw!==null&&this.Lw.Rm(e),this.zw!==null&&this.zw.Rm(e)}this.Mm.applySuggestedBitmapSize();let n=vS(this.Mm,t);n!==null&&(n.useBitmapCoordinateSpace((({context:e,bitmapSize:t})=>{e.clearRect(0,0,t.width,t.height)})),this.Jw([...this.Gv.Qt().Jn(),this.Gv.Qt().Vd()],n),this.Xw(n,aE))}Xw(e,t){let n=this.Gv.Qt().Jn();for(let r of n)KT(t,(t=>WT(t,e,!1,void 0)),r,void 0);for(let r of n)KT(t,(t=>GT(t,e,!1,void 0)),r,void 0)}Im({context:e,bitmapSize:t}){ZS(e,0,0,t.width,t.height,this.Gv.Qt().af())}Vm({context:e,bitmapSize:t,verticalPixelRatio:n}){if(this.Gv.N().timeScale.borderVisible){e.fillStyle=this.Qw();let r=Math.max(1,Math.floor(this.Gw().S*n));e.fillRect(0,0,t.width,r)}}Em(e){let t=this.Gv.Qt().Et(),n=t.zl();if(!n||n.length===0)return;let r=this.Pu.maxTickMarkWeight(n),i=this.Gw(),a=t.N();a.borderVisible&&a.ticksVisible&&e.useBitmapCoordinateSpace((({context:e,horizontalPixelRatio:t,verticalPixelRatio:r})=>{e.strokeStyle=this.Qw(),e.fillStyle=this.Qw();let a=Math.max(1,Math.floor(t)),o=Math.floor(.5*t);e.beginPath();let s=Math.round(i.C*r);for(let r=n.length;r--;){let i=Math.round(n[r].coord*t);e.rect(i-o,0,a,s)}e.fill()})),e.useMediaCoordinateSpace((({context:e})=>{let t=i.S+i.C+i.A+i.P/2;e.textAlign=`center`,e.textBaseline=`middle`,e.fillStyle=this.H(),e.font=this.ym();for(let i of n)if(i.weight<r){let n=i.needAlignCoordinate?this.tM(e,i.coord,i.label):i.coord;e.fillText(i.label,n,t)}this.Gv.N().timeScale.allowBoldLabels&&(e.font=this.iM());for(let i of n)if(i.weight>=r){let n=i.needAlignCoordinate?this.tM(e,i.coord,i.label):i.coord;e.fillText(i.label,n,t)}}))}tM(e,t,n){let r=this.rm.Ii(e,n),i=r/2,a=Math.floor(t-i)+.5;return a<0?t+=Math.abs(0-a):a+r>this.nm.width&&(t-=Math.abs(this.nm.width-(a+r))),t}Jw(e,t){let n=this.Gw();for(let r of e)for(let e of r.dn())e.Tt().st(t,n)}Qw(){return this.Gv.N().timeScale.borderColor}H(){return this.yn.textColor}F(){return this.yn.fontSize}ym(){return LS(this.F(),this.yn.fontFamily)}iM(){return LS(this.F(),this.yn.fontFamily,`bold`)}Gw(){this.M===null&&(this.M={S:1,L:NaN,A:NaN,I:NaN,tn:NaN,C:5,P:NaN,k:``,Qi:new yC,Zw:0});let e=this.M,t=this.ym();if(e.k!==t){let n=this.F();e.P=n,e.k=t,e.A=3*n/12,e.I=3*n/12,e.tn=9*n/12,e.L=0,e.Zw=4*n/12,e.Qi.Os()}return this.M}zm(e){this.uv.style.cursor=e===1?`ew-resize`:`default`}Uw(){let e=this.Gv.Qt(),t=e.N();t.leftPriceScale.visible||this.Lw===null||(this.Fw.removeChild(this.Lw.fv()),this.Lw.m(),this.Lw=null),t.rightPriceScale.visible||this.zw===null||(this.Ww.removeChild(this.zw.fv()),this.zw.m(),this.zw=null);let n={Jd:this.Gv.Qt().Jd()},r=()=>t.leftPriceScale.borderVisible&&e.Et().N().borderVisible,i=()=>e.af();t.leftPriceScale.visible&&this.Lw===null&&(this.Lw=new nE(`left`,t,n,r,i),this.Fw.appendChild(this.Lw.fv())),t.rightPriceScale.visible&&this.zw===null&&(this.zw=new nE(`right`,t,n,r,i),this.Ww.appendChild(this.zw.fv()))}},cE=!!TT&&!!navigator.userAgentData&&navigator.userAgentData.brands.some((e=>e.brand.includes(`Chromium`)))&&!!TT&&(navigator?.userAgentData?.platform?navigator.userAgentData.platform===`Windows`:navigator.userAgent.toLowerCase().indexOf(`win`)>=0),lE=class{constructor(e,t,n){var r;this.nM=[],this.sM=[],this.eM=0,this.oo=0,this.k_=0,this.rM=0,this.hM=0,this.aM=null,this.lM=!1,this.$m=new DS,this.jm=new DS,this.wd=new DS,this.oM=null,this._M=null,this.Kv=e,this.yn=t,this.Pu=n,this.jv=document.createElement(`div`),this.jv.classList.add(`tv-lightweight-charts`),this.jv.style.overflow=`hidden`,this.jv.style.direction=`ltr`,this.jv.style.width=`100%`,this.jv.style.height=`100%`,(r=this.jv).style.userSelect=`none`,r.style.webkitUserSelect=`none`,r.style.msUserSelect=`none`,r.style.MozUserSelect=`none`,r.style.webkitTapHighlightColor=`transparent`,this.uM=document.createElement(`table`),this.uM.setAttribute(`cellspacing`,`0`),this.jv.appendChild(this.uM),this.cM=this.dM.bind(this),uE(this.yn)&&this.fM(!0),this.sn=new aT(this.gd.bind(this),this.yn,n),this.Qt().Bd().i(this.pM.bind(this),this),this.vM=new sE(this,this.Pu),this.uM.appendChild(this.vM.fv());let i=t.autoSize&&this.mM(),a=this.yn.width,o=this.yn.height;if(i||a===0||o===0){let t=e.getBoundingClientRect();a||=t.width,o||=t.height}this.wM(a,o),this.MM(),e.appendChild(this.jv),this.gM(),this.sn.Et().Jc().i(this.sn.ka.bind(this.sn),this),this.sn.N_().i(this.sn.ka.bind(this.sn),this)}Qt(){return this.sn}N(){return this.yn}lv(){return this.nM}bM(){return this.vM}m(){this.fM(!1),this.eM!==0&&window.cancelAnimationFrame(this.eM),this.sn.Bd().u(this),this.sn.Et().Jc().u(this),this.sn.N_().u(this),this.sn.m();for(let e of this.nM)this.uM.removeChild(e.fv()),e.mw().u(this),e.ww().u(this),e.m();this.nM=[];for(let e of this.sM)this.SM(e);this.sM=[],$(this.vM).m(),this.jv.parentElement!==null&&this.jv.parentElement.removeChild(this.jv),this.wd.m(),this.$m.m(),this.jm.m(),this.xM()}wM(e,t,n=!1){if(this.oo===t&&this.k_===e)return;let r=function(e){let t=Math.floor(e.width),n=Math.floor(e.height);return Q({width:t-t%2,height:n-n%2})}(Q({width:e,height:t}));this.oo=r.height,this.k_=r.width;let i=this.oo+`px`,a=this.k_+`px`;if(this.CM()||($(this.jv).style.height=i,$(this.jv).style.width=a),this.uM.style.height=i,this.uM.style.width=a,n){this.eM!==0&&(window.cancelAnimationFrame(this.eM),this.eM=0),this.lM=!1;let e=dC.ys();this.aM!==null&&(e.Ss(this.aM),this.aM=null),this.yM(e,performance.now())}else this.sn.ka()}Rm(e){e===void 0&&(e=dC.ys());for(let t=0;t<this.nM.length;t++)this.nM[t].Rm(e._s(t).rs);this.yn.timeScale.visible&&this.vM.Rm(e.ls())}vr(e){let t=uE(this.yn);this.sn.vr(e);let n=uE(this.yn);n!==t&&this.fM(n),e.layout?.panes&&this.PM(),this.gM(),this.kM(e)}mw(){return this.$m}ww(){return this.jm}Bd(){return this.wd}TM(e=!1){this.aM!==null&&(this.yM(this.aM,performance.now()),this.aM=null);let t=this.RM(null),n=document.createElement(`canvas`);n.width=t.width,n.height=t.height;let r=$(n.getContext(`2d`));return this.RM(r,e),n}DM(e){return e===`left`&&!this.IM()||e===`right`&&!this.VM()||this.nM.length===0?0:$(e===`left`?this.nM[0].yw():this.nM[0].Pw()).Tm()}CM(){return this.yn.autoSize&&this.oM!==null}Mv(){return this.jv}BM(e){this._M=e,this._M?this.Mv().style.setProperty(`cursor`,e):this.Mv().style.removeProperty(`cursor`)}EM(){return this._M}AM(e){return TS(this.nM[e]).pv()}PM(){this.sM.forEach((e=>{e.Pt()}))}kM(e){(e.autoSize!==void 0||!this.oM||e.width===void 0&&e.height===void 0)&&(e.autoSize&&!this.oM&&this.mM(),!1===e.autoSize&&this.oM!==null&&this.xM(),e.autoSize||e.width===void 0&&e.height===void 0||this.wM(e.width||this.k_,e.height||this.oo))}RM(e,t){let n=0,r=0,i=this.nM[0],a=(n,r)=>{let i=0;for(let a=0;a<this.nM.length;a++){let o=this.nM[a],s=$(n===`left`?o.yw():o.Pw()),c=s.vv();if(e!==null&&s.mv(e,r,i,t),i+=c.height,a<this.nM.length-1){let t=this.sM[a],n=t.vv();e!==null&&t.mv(e,r,i),i+=n.height}}};this.IM()&&(a(`left`,0),n+=$(i.yw()).vv().width);for(let i=0;i<this.nM.length;i++){let a=this.nM[i],o=a.vv();if(e!==null&&a.mv(e,n,r,t),r+=o.height,i<this.nM.length-1){let t=this.sM[i],a=t.vv();e!==null&&t.mv(e,n,r),r+=a.height}}n+=i.vv().width,this.VM()&&(a(`right`,n),n+=$(i.Pw()).vv().width);let o=(t,n,r)=>{$(t===`left`?this.vM.$w():this.vM.jw()).mv($(e),n,r)};if(this.yn.timeScale.visible){let n=this.vM.vv();if(e!==null){let a=0;this.IM()&&(o(`left`,a,r),a=$(i.yw()).vv().width),this.vM.mv(e,a,r,t),a+=n.width,this.VM()&&o(`right`,a,r)}r+=n.height}return Q({width:n,height:r})}LM(){let e=0,t=0,n=0;for(let r of this.nM)this.IM()&&(t=Math.max(t,$(r.yw()).Cm(),this.yn.leftPriceScale.minimumWidth)),this.VM()&&(n=Math.max(n,$(r.Pw()).Cm(),this.yn.rightPriceScale.minimumWidth)),e+=r.F_();t=kT(t),n=kT(n);let r=this.k_,i=this.oo,a=Math.max(r-t-n,0),o=1*this.sM.length,s=this.yn.timeScale.visible,c=s?Math.max(this.vM.Kw(),this.yn.timeScale.minimumHeight):0;var l;c=(l=c)+l%2;let u=o+c,d=i<u?0:i-u,f=d/e,p=0,m=window.devicePixelRatio||1;for(let e=0;e<this.nM.length;++e){let r=this.nM[e];r.ew(this.sn.Gn()[e]);let i=0,o=0;o=e===this.nM.length-1?Math.ceil((d-p)*m)/m:Math.round(r.F_()*f*m)/m,i=Math.max(o,2),p+=i,r.km(Q({width:a,height:i})),this.IM()&&r.gw(t,`left`),this.VM()&&r.gw(n,`right`),r.yv()&&this.sn.Ed(r.yv(),i)}this.vM.Yw(Q({width:s?a:0,height:c}),s?t:0,s?n:0),this.sn.H_(a),this.rM!==t&&(this.rM=t),this.hM!==n&&(this.hM=n)}fM(e){e?this.jv.addEventListener(`wheel`,this.cM,{passive:!1}):this.jv.removeEventListener(`wheel`,this.cM)}zM(e){switch(e.deltaMode){case e.DOM_DELTA_PAGE:return 120;case e.DOM_DELTA_LINE:return 32}return cE?1/window.devicePixelRatio:1}dM(e){if(!(e.deltaX!==0&&this.yn.handleScroll.mouseWheel||e.deltaY!==0&&this.yn.handleScale.mouseWheel))return;let t=this.zM(e),n=t*e.deltaX/100,r=-t*e.deltaY/100;if(e.cancelable&&e.preventDefault(),r!==0&&this.yn.handleScale.mouseWheel){let t=Math.sign(r)*Math.min(1,Math.abs(r)),n=e.clientX-this.jv.getBoundingClientRect().left;this.Qt().Wd(n,t)}n!==0&&this.yn.handleScroll.mouseWheel&&this.Qt().Hd(-80*n)}yM(e,t){let n=e.ls();n===3&&this.OM(),n!==3&&n!==2||(this.NM(e),this.FM(e,t),this.vM.Pt(),this.nM.forEach((e=>{e.hw()})),this.aM?.ls()===3&&(this.aM.Ss(e),this.OM(),this.NM(this.aM),this.FM(this.aM,t),e=this.aM,this.aM=null)),this.Rm(e)}FM(e,t){for(let n of e.bs())this.xs(n,t)}NM(e){let t=this.sn.Gn();for(let n=0;n<t.length;n++)e._s(n).hs&&t[n].lu()}xs(e,t){let n=this.sn.Et();switch(e.ds){case 0:n.td();break;case 1:n.nd(e.Wt);break;case 2:n.Ms(e.Wt);break;case 3:n.gs(e.Wt);break;case 4:n.Wc();break;case 5:e.Wt.Kc(t)||n.gs(e.Wt.Gc(t))}}gd(e){this.aM===null?this.aM=e:this.aM.Ss(e),this.lM||(this.lM=!0,this.eM=window.requestAnimationFrame((e=>{if(this.lM=!1,this.eM=0,this.aM!==null){let t=this.aM;this.aM=null,this.yM(t,e);for(let n of t.bs())if(n.ds===5&&!n.Wt.Kc(e)){this.Qt().ps(n.Wt);break}}})))}OM(){this.MM()}SM(e){this.uM.removeChild(e.fv()),e.m()}MM(){let e=this.sn.Gn(),t=e.length,n=this.nM.length;for(let e=t;e<n;e++){let e=TS(this.nM.pop());this.uM.removeChild(e.fv()),e.mw().u(this),e.ww().u(this),e.m();let t=this.sM.pop();t!==void 0&&this.SM(t)}for(let r=n;r<t;r++){let t=new tE(this,e[r]);if(t.mw().i(this.WM.bind(this,t),this),t.ww().i(this.HM.bind(this,t),this),this.nM.push(t),r>0){let e=new LT(this,r-1,r);this.sM.push(e),this.uM.insertBefore(e.fv(),this.vM.fv())}this.uM.insertBefore(t.fv(),this.vM.fv())}for(let n=0;n<t;n++){let t=e[n],r=this.nM[n];r.yv()===t?r.sw():r.ew(t)}this.gM(),this.LM()}UM(e,t,n,r){let i=new Map;e!==null&&this.sn.Jn().forEach((t=>{let n=t.Un().Hn(e);n!==null&&i.set(t,n)}));let a;if(e!==null){let t=this.sn.Et().en(e)?.originalTime;t!==void 0&&(a=t)}let o=this.Qt().cu(),s=this.$M(r),c=function(e,t){let n=e!==null&&e.uu instanceof fw?e.uu:void 0,r=e?.bu?.te,i=t!==void 0&&t!==-1?t:void 0;return e===null||e.ee===void 0?{jM:n,qM:r}:{jM:n,qM:r,YM:{ds:e.ee,KM:(a=e.uu,o=e.ee,a instanceof zw?`pane-primitive`:o===`marker`||o===`primitive`?`series-primitive`:`series`),GM:OT(e.ee,r),Y_:n,ZM:r,XM:i}};var a,o}(o,s);return{Qr:a,$n:e??void 0,JM:t??void 0,XM:s===-1?void 0:s,jM:c.jM,QM:i,qM:c.qM,YM:c.YM,tg:n??void 0}}$M(e){let t=-1;if(e)t=this.nM.indexOf(e);else{let e=this.Qt().Vd().Kn();e!==null&&(t=this.Qt().Gn().indexOf(e))}return t}WM(e,t,n,r){this.$m.p((()=>this.UM(t,n,r,e)))}HM(e,t,n,r){this.jm.p((()=>this.UM(t,n,r,e)))}pM(e,t,n){this.BM(this.Qt().cu()?.gu??null),this.wd.p((()=>this.UM(e,t,n)))}gM(){let e=this.yn.timeScale.visible?``:`none`;this.vM.fv().style.display=e}IM(){return this.nM[0].yv().X_().N().visible}VM(){return this.nM[0].yv().J_().N().visible}mM(){return`ResizeObserver`in window&&(this.oM=new ResizeObserver((e=>{let t=e[e.length-1];if(!t)return;let n=t.contentRect.width,r=t.contentRect.height;this.wM(n,r,!0)})),this.oM.observe(this.Kv,{box:`border-box`}),!0)}xM(){this.oM!==null&&this.oM.disconnect(),this.oM=null}};function uE(e){return!!(e.handleScroll.mouseWheel||e.handleScale.mouseWheel)}function dE(e){return e.open===void 0&&e.value===void 0}function fE(e){return function(e){return e.open!==void 0}(e)||function(e){return e.value!==void 0}(e)}function pE(e,t,n,r){let i=n.value,a={$n:t,wt:e,Wt:[i,i,i,i],Qr:r};return n.color!==void 0&&(a.R=n.color),a}function mE(e,t,n,r){let i=n.value,a={$n:t,wt:e,Wt:[i,i,i,i],Qr:r};return n.lineColor!==void 0&&(a.vt=n.lineColor),n.topColor!==void 0&&(a.ah=n.topColor),n.bottomColor!==void 0&&(a.oh=n.bottomColor),a}function hE(e,t,n,r){let i=n.value,a={$n:t,wt:e,Wt:[i,i,i,i],Qr:r};return n.topLineColor!==void 0&&(a._h=n.topLineColor),n.bottomLineColor!==void 0&&(a.uh=n.bottomLineColor),n.topFillColor1!==void 0&&(a.dh=n.topFillColor1),n.topFillColor2!==void 0&&(a.fh=n.topFillColor2),n.bottomFillColor1!==void 0&&(a.ph=n.bottomFillColor1),n.bottomFillColor2!==void 0&&(a.mh=n.bottomFillColor2),a}function gE(e,t,n,r){let i={$n:t,wt:e,Wt:[n.open,n.high,n.low,n.close],Qr:r};return n.color!==void 0&&(i.R=n.color),i}function _E(e,t,n,r){let i={$n:t,wt:e,Wt:[n.open,n.high,n.low,n.close],Qr:r};return n.color!==void 0&&(i.R=n.color),n.borderColor!==void 0&&(i.Ht=n.borderColor),n.wickColor!==void 0&&(i.hh=n.wickColor),i}function vE(e,t,n,r,i){let a=TS(i)(n),o=Math.max(...a),s=Math.min(...a),c=a[a.length-1],l=[c,o,s,c],{time:u,color:d,...f}=n;return{$n:t,wt:e,Wt:l,Qr:r,ue:f,R:d}}function yE(e){return e.Wt!==void 0}function bE(e,t){return t.customValues!==void 0&&(e.ig=t.customValues),e}function xE(e){return(t,n,r,i,a,o)=>function(e,t){return t?t(e):dE(e)}(r,o)?bE({wt:t,$n:n,Qr:i},r):bE(e(t,n,r,i,a),r)}function SE(e){return{Candlestick:xE(_E),Bar:xE(gE),Area:xE(mE),Baseline:xE(hE),Histogram:xE(pE),Line:xE(pE),Custom:xE(vE)}[e]}function CE(e){return{$n:0,ng:new Map,Oa:e}}function wE(e,t){if(e!==void 0&&e.length!==0)return{sg:t.key(e[0].wt),eg:t.key(e[e.length-1].wt)}}function TE(e){let t;return e.forEach((e=>{t===void 0&&(t=e.Qr)})),TS(t)}var EE=class{constructor(e){this.rg=new Map,this.hg=new Map,this.ag=new Map,this.lg=[],this.Pu=e}m(){this.rg.clear(),this.hg.clear(),this.ag.clear(),this.lg=[]}og(e,t){let n=this.rg.size!==0,r=!1,i=this.hg.get(e);if(i!==void 0){if(this.hg.size===1)n=!1,r=!0,this.rg.clear();else for(let t of this.lg)t.pointData.ng.delete(e)&&(r=!0)}let a=[];if(t.length!==0){let n=t.map((e=>e.time)),i=this.Pu.createConverterToInternalObj(t),o=SE(e.bh()),s=e.ul(),c=e.cl();a=t.map(((t,a)=>{let l=i(t.time),u=this.Pu.key(l),d=this.rg.get(u);d===void 0&&(d=CE(l),this.rg.set(u,d),r=!0);let f=o(l,d.$n,t,n[a],s,c);return d.ng.set(e,f),f}))}n&&this._g(),this.ug(e,a);let o=-1;if(r){let e=[];this.rg.forEach((t=>{e.push({timeWeight:0,time:t.Oa,pointData:t,originalTime:TE(t.ng)})})),e.sort(((e,t)=>this.Pu.key(e.time)-this.Pu.key(t.time))),o=this.cg(e)}return this.dg(e,o,function(e,t,n){let r=wE(e,n),i=wE(t,n);if(r!==void 0&&i!==void 0)return{fg:!1,Va:r.eg>=i.eg&&r.sg>=i.sg}}(this.hg.get(e),i,this.Pu))}if(e){return this.og(e,[])}pg(e,t,n){if(n&&e.Fa())throw Error(`Historical updates are not supported when conflation is enabled. Conflation requires data to be processed in order.`);let r=t;(function(e){e.Qr===void 0&&(e.Qr=e.time)})(r),this.Pu.preprocessData(t);let i=this.Pu.createConverterToInternalObj([t])(t.time),a=this.ag.get(e);if(!n&&a!==void 0&&this.Pu.key(i)<this.Pu.key(a))throw Error(`Cannot update oldest data, last time=${a}, new time=${i}`);let o=this.rg.get(this.Pu.key(i));if(n&&o===void 0)throw Error(`Cannot update non-existing data point when historicalUpdate is true`);let s=o===void 0;o===void 0&&(o=CE(i),this.rg.set(this.Pu.key(i),o));let c=SE(e.bh()),l=e.ul(),u=e.cl(),d=c(i,o.$n,t,r.Qr,l,u),f=!n&&!s&&a!==void 0&&this.Pu.key(i)===this.Pu.key(a);o.ng.set(e,d),n?this.vg(e,d,o.$n):(f&&e.Fa()&&yE(d)&&e.Rr(d),this.mg(e,d));let p={Va:yE(d),fg:n};if(!s)return this.dg(e,-1,p);let m={timeWeight:0,time:o.Oa,pointData:o,originalTime:TE(o.ng)},h=UC(this.lg,this.Pu.key(m.time),((e,t)=>this.Pu.key(e.time)<t));this.lg.splice(h,0,m);for(let e=h;e<this.lg.length;++e)DE(this.lg[e].pointData,e);return this.Pu.fillWeightsForPoints(this.lg,h),this.dg(e,h,p)}wg(e,t){let n=this.hg.get(e);if(n===void 0||t<=0)return[[],this.Mg()];t=Math.min(t,n.length);let r=n.splice(-t).reverse();n.length===0?this.ag.delete(e):this.ag.set(e,n[n.length-1].wt);for(let t of r){let n=this.rg.get(this.Pu.key(t.wt));if(n&&(n.ng.delete(e),n.ng.size===0)){this.rg.delete(this.Pu.key(n.Oa)),this.lg.splice(n.$n,1);for(let e=n.$n;e<this.lg.length;++e)DE(this.lg[e].pointData,e)}}return[r,this.dg(e,this.lg.length-1,{fg:!1,Va:!1})]}mg(e,t){let n=this.hg.get(e);n===void 0&&(n=[],this.hg.set(e,n));let r=n.length===0?null:n[n.length-1];r===null||this.Pu.key(t.wt)>this.Pu.key(r.wt)?yE(t)&&n.push(t):yE(t)?n[n.length-1]=t:n.splice(-1,1),this.ag.set(e,t.wt)}vg(e,t,n){let r=this.hg.get(e);if(r===void 0)return;let i=UC(r,n,((e,t)=>e.$n<t));yE(t)?r[i]=t:r.splice(i,1)}ug(e,t){t.length===0?(this.hg.delete(e),this.ag.delete(e)):(this.hg.set(e,t.filter(yE)),this.ag.set(e,t[t.length-1].wt))}_g(){for(let e of this.lg)e.pointData.ng.size===0&&this.rg.delete(this.Pu.key(e.time))}cg(e){let t=-1;for(let n=0;n<this.lg.length&&n<e.length;++n){let r=this.lg[n],i=e[n];if(this.Pu.key(r.time)!==this.Pu.key(i.time)){t=n;break}i.timeWeight=r.timeWeight,DE(i.pointData,n)}if(t===-1&&this.lg.length!==e.length&&(t=Math.min(this.lg.length,e.length)),t===-1)return-1;for(let n=t;n<e.length;++n)DE(e[n].pointData,n);return this.Pu.fillWeightsForPoints(e,t),this.lg=e,t}gg(){if(this.hg.size===0)return null;let e=0;return this.hg.forEach((t=>{t.length!==0&&(e=Math.max(e,t[t.length-1].$n))})),e}dg(e,t,n){let r=this.Mg();if(t!==-1)this.hg.forEach(((t,i)=>{r.Y_.set(i,{ue:t,bg:i===e?n:void 0})})),this.hg.has(e)||r.Y_.set(e,{ue:[],bg:n}),r.Et.Sg=this.lg,r.Et.xg=t;else{let t=this.hg.get(e);r.Y_.set(e,{ue:t||[],bg:n})}return r}Mg(){return{Y_:new Map,Et:{Dc:this.gg()}}}};function DE(e,t){e.$n=t,e.ng.forEach((e=>{e.$n=t}))}function OE(e,t){return e._t<t}function kE(e,t){return t<e._t}function AE(e,t,n,r){return UC(e,t,OE,n,r)}function jE(e,t,n,r){return WC(e,t,kE,n,r)}function ME(e,t,n){return{ne:e,se:t,ee:n}}var NE=[0,0];function PE(e,t,n){return t===void 0||t.wt!==e.wt-1?e._t-n/2:(t._t+e._t)/2}function FE(e,t,n){return t===void 0||t.wt!==e.wt+1?e._t+n/2:(e._t+t._t)/2}function IE(e,t,n,r,i,a,o){if(t===null||t.from>=t.to||e.length===0)return null;let s=i/2+a,c=AE(e,n-s,t.from,t.to),l=jE(e,n+s,c,t.to);if(c>=l)return null;let u=1/0;for(let s=c;s<l;s++){let c=e[s],l=s>t.from?e[s-1]:void 0,d=s<t.to-1?e[s+1]:void 0,f=PE(c,l,i)-a,p=FE(c,d,i)+a;if(n<f||n>p)continue;o(c,NE);let m=NE[0],h=NE[1],g=Math.min(m,h),_=Math.max(m,h),v=g-a,y=_+a;if(r>=g&&r<=_)u=Math.min(u,0);else if(r>=v&&r<=y){let e=Math.min(Math.abs(r-g),Math.abs(_-r));u=Math.min(u,e)}}return Number.isFinite(u)?ME(u,0,`series-range`):null}function LE(e,t){return e.wt<t}function RE(e,t){return t<e.wt}function zE(e,t,n){let r=t.Na(),i=t.bi(),a=UC(e,r,LE),o=WC(e,i,RE);if(!n)return{from:a,to:o};let s=a,c=o;return a>0&&a<e.length&&e[a].wt>=r&&(s=a-1),o>0&&o<e.length&&e[o-1].wt<=i&&(c=o+1),{from:s,to:c}}var BE=class{constructor(e,t,n){this.Cg=!0,this.yg=!0,this.Pg=!0,this.kg=[],this.Tg=null,this.Rg=-1,this.ae=e,this.le=t,this.Dg=n}Pt(e){this.Cg=!0,e===`data`&&(this.yg=!0),e===`options`&&(this.Pg=!0)}Tt(){return this.ae.It()?(this.Ig(),this.Tg===null?null:this.Vg):null}Qs(e,t){return this.ae.It()?(this.Ig(),this.Tg===null?null:this.Bg(e,t)):null}Bg(e,t){return null}Eg(){this.kg=this.kg.map((e=>({...e,...this.ae.Sa().Sh(e.wt)})))}Ag(){this.Tg=null}Ig(){let e=this.le.Et(),t=e.N().enableConflation?e.sd():0;t!==this.Rg&&(this.yg=!0,this.Rg=t),this.yg&&=(this.Lg(),!1),this.Pg&&=(this.Eg(),!1),this.Cg&&=(this.zg(),!1)}zg(){let e=this.ae.Ft(),t=this.le.Et();if(this.Ag(),t.Zi()||e.Zi())return;let n=t.Ee();if(n===null||this.ae.Un().Th()===0)return;let r=this.ae.Lt();r!==null&&(this.Tg=zE(this.kg,n,this.Dg),this.Og(e,t,r.Wt),this.Ng())}},VE=class{constructor(e,t){this.Fg=e,this.Ki=t}st(e,t,n){this.Fg.draw(e,this.Ki,t,n)}};function HE(e){switch(e){case`point`:return 2;case`range`:return 0;default:return 1}}var UE=class extends BE{constructor(e,t,n){super(e,t,!1),this.Yh=n,this.Fg=this.Yh.renderer(),this.Vg=new VE(this.Fg,(e=>this.Wg(e)))}get ga(){return this.Yh.conflationReducer}Ha(e){return this.Yh.priceValueBuilder(e)}dl(e){return this.Yh.isWhitespace(e)}Bg(e,t){let n=this.Fg.hitTest?.(e,t,(e=>this.Wg(e)));if(n!=null)return{ne:(r=n).distance,se:HE(r.type),ee:`custom`,gu:r.cursorStyle,te:r.objectId,ie:r.hitTestData};var r;let i=IE(this.kg,this.Tg,e,t,this.le.Et().ml(),this.ae.N().hitTestTolerance,((e,t)=>{let n=e.Hg,r=NaN,i=NaN;if(n!==void 0&&!this.Yh.isWhitespace(n))for(let e of this.Yh.priceValueBuilder(n)){let t=this.Wg(e);t!==null&&(r=Number.isNaN(r)?t:Math.min(r,t),i=Number.isNaN(i)?t:Math.max(i,t))}t[0]=r,t[1]=i}));return i===null?null:{...i,ee:`custom`}}Lg(){let e=this.ae.Sa();this.kg=this.ae.Ua().Bh().map((t=>({wt:t.$n,_t:NaN,...e.Sh(t.$n),Hg:t.ue})))}Og(e,t){t.Ic(this.kg,FS(this.Tg))}Ng(){this.Yh.update({bars:this.kg.map(WE),barSpacing:this.le.Et().ml(),visibleRange:this.Tg,conflationFactor:this.le.Et().sd()},this.ae.N())}Wg(e){let t=this.ae.Lt();return t===null?null:this.ae.Ft().Nt(e,t.Wt)}};function WE(e){return{x:e._t,time:e.wt,originalData:e.Hg,barColor:e.sh}}var GE={color:`#2196f3`},KE=(e,t,n)=>new UE(e,t,ES(n));function qE(e){let t={value:e.Wt[3],time:e.Qr};return e.ig!==void 0&&(t.customValues=e.ig),t}function JE(e){let t=qE(e);return e.R!==void 0&&(t.color=e.R),t}function YE(e){let t=qE(e);return e.vt!==void 0&&(t.lineColor=e.vt),e.ah!==void 0&&(t.topColor=e.ah),e.oh!==void 0&&(t.bottomColor=e.oh),t}function XE(e){let t=qE(e);return e._h!==void 0&&(t.topLineColor=e._h),e.uh!==void 0&&(t.bottomLineColor=e.uh),e.dh!==void 0&&(t.topFillColor1=e.dh),e.fh!==void 0&&(t.topFillColor2=e.fh),e.ph!==void 0&&(t.bottomFillColor1=e.ph),e.mh!==void 0&&(t.bottomFillColor2=e.mh),t}function ZE(e){let t={open:e.Wt[0],high:e.Wt[1],low:e.Wt[2],close:e.Wt[3],time:e.Qr};return e.ig!==void 0&&(t.customValues=e.ig),t}function QE(e){let t=ZE(e);return e.R!==void 0&&(t.color=e.R),t}function $E(e){let t=ZE(e),{R:n,Ht:r,hh:i}=e;return n!==void 0&&(t.color=n),r!==void 0&&(t.borderColor=r),i!==void 0&&(t.wickColor=i),t}function eD(e){return{Area:YE,Line:JE,Baseline:XE,Histogram:JE,Bar:QE,Candlestick:$E,Custom:tD}[e]}function tD(e){let t=e.Qr;return{...e.ue,time:t}}var nD={vertLine:{color:`#9598A1`,width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:`#131722`},horzLine:{color:`#9598A1`,width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:`#131722`},mode:1,doNotSnapToHiddenSeriesIndices:!1},rD={vertLines:{color:`#D6DCDE`,style:0,visible:!0},horzLines:{color:`#D6DCDE`,style:0,visible:!0}},iD={background:{type:`solid`,color:`#FFFFFF`},textColor:`#191919`,fontSize:12,fontFamily:IS,panes:{enableResize:!0,separatorColor:`#E0E3EB`,separatorHoverColor:`rgba(178, 181, 189, 0.2)`},attributionLogo:!0,colorSpace:`srgb`,colorParsers:[]},aD={autoScale:!0,mode:0,invertScale:!1,alignLabels:!0,borderVisible:!0,borderColor:`#2B2B43`,entireTextOnly:!1,visible:!1,ticksVisible:!1,scaleMargins:{bottom:.1,top:.2},minimumWidth:0,ensureEdgeTickMarksVisible:!1,tickMarkDensity:2.5},oD={rightOffset:0,barSpacing:6,minBarSpacing:.5,maxBarSpacing:0,fixLeftEdge:!1,fixRightEdge:!1,lockVisibleTimeRangeOnResize:!1,rightBarStaysOnScroll:!1,borderVisible:!0,borderColor:`#2B2B43`,visible:!0,timeVisible:!1,secondsVisible:!0,shiftVisibleRangeOnNewBar:!0,allowShiftVisibleRangeOnWhitespaceReplacement:!1,ticksVisible:!1,uniformDistribution:!1,minimumHeight:0,allowBoldLabels:!0,ignoreWhitespaceIndices:!1,enableConflation:!1,conflationThresholdFactor:1,precomputeConflationOnInit:!1,precomputeConflationPriority:`background`};function sD(){return{addDefaultPane:!0,hoveredSeriesOnTop:!0,width:0,height:0,autoSize:!1,layout:iD,crosshair:nD,grid:rD,overlayPriceScales:{...aD},leftPriceScale:{...aD,visible:!1},rightPriceScale:{...aD,visible:!0},defaultVisiblePriceScaleId:`right`,timeScale:oD,localization:{locale:TT?navigator.language:``,dateFormat:`dd MMM 'yy`},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0},handleScale:{axisPressedMouseMove:{time:!0,price:!0},axisDoubleClickReset:{time:!0,price:!0},mouseWheel:!0,pinch:!0},kineticScroll:{mouse:!1,touch:!0},trackingMode:{exitMode:1}}}var cD=class{constructor(e,t,n){this.hv=e,this.Ug=t,this.$g=n??0}applyOptions(e){this.hv.Qt().Dd(this.Ug,e,this.$g)}options(){return this.Ki().N()}width(){return uC(this.Ug)?this.hv.DM(this.Ug):0}setVisibleRange(e){this.setAutoScale(!1),this.Ki().Go(new jC(e.from,e.to))}getVisibleRange(){let e,t,n=this.Ki().ar();if(n===null)return null;if(this.Ki().ho()){let r=this.Ki().S_(),i=oT(r);n=kw(n,this.Ki().lo()),e=Number((Math.round(n.Je()/r)*r).toFixed(i)),t=Number((Math.round(n.Qe()/r)*r).toFixed(i))}else e=n.Je(),t=n.Qe();return{from:e,to:t}}setAutoScale(e){this.applyOptions({autoScale:e})}Ki(){return $(this.hv.Qt().Id(this.Ug,this.$g)).Ft}},lD=class{constructor(e,t,n,r){this.hv=e,this.yt=n,this.jg=t,this.qg=r}getHeight(){return this.yt.$t()}setHeight(e){let t=this.hv.Qt(),n=t._f(this.yt);t.Ld(n,e)}getStretchFactor(){return this.yt.F_()}setStretchFactor(e){this.yt.W_(e),this.hv.Qt().ka()}paneIndex(){return this.hv.Qt()._f(this.yt)}moveTo(e){let t=this.paneIndex();t!==e&&(wS(e>=0&&e<this.hv.lv().length,`Invalid pane index`),this.hv.Qt().Od(t,e))}getSeries(){return this.yt.Y_().map((e=>this.jg(e)))??[]}getHTMLElement(){let e=this.hv.lv();return e&&e.length!==0&&e[this.paneIndex()]?e[this.paneIndex()].fv():null}attachPrimitive(e){this.yt.ol(e),e.attached&&e.attached({chart:this.qg,requestUpdate:()=>this.yt.Qt().ka()})}detachPrimitive(e){this.yt._l(e)}priceScale(e){if(this.yt.O_(e)===null)throw Error(`Cannot find price scale with id: ${e}`);return new cD(this.hv,e,this.paneIndex())}setPreserveEmptyPane(e){this.yt.j_(e)}preserveEmptyPane(){return this.yt.q_()}addCustomSeries(e,t={},n=0){return this.qg.addCustomSeries(e,t,n)}addSeries(e,t={}){return this.qg.addSeries(e,t,this.paneIndex())}},uD={color:`#FF0000`,price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:``,axisLabelColor:``,axisLabelTextColor:``},dD=class{constructor(e){this._r=e}applyOptions(e){this._r.vr(e)}options(){return this._r.N()}Yg(){return this._r}},fD=class{constructor(e,t,n,r,i,a){this.Kg=new DS,this.ae=e,this.Gg=t,this.Zg=n,this.Pu=i,this.qg=r,this.Xg=a}m(){this.Kg.m()}priceFormatter(){return this.ae.sl()}priceToCoordinate(e){let t=this.ae.Lt();return t===null?null:this.ae.Ft().Nt(e,t.Wt)}coordinateToPrice(e){let t=this.ae.Lt();return t===null?null:this.ae.Ft().Tn(e,t.Wt)}barsInLogicalRange(e){if(e===null)return null;let t=new Zw(new Jw(e.from,e.to)).Uu(),n=this.ae.Un();if(n.Zi())return null;let r=n.Hn(t.Na(),1),i=n.Hn(t.bi(),-1),a=$(n.Rh()),o=$(n.Qn());if(r!==null&&i!==null&&r.$n>i.$n)return{barsBefore:e.from-a,barsAfter:o-e.to};let s={barsBefore:r===null||r.$n===a?e.from-a:r.$n-a,barsAfter:i===null||i.$n===o?o-e.to:o-i.$n};return r!==null&&i!==null&&(s.from=r.Qr,s.to=i.Qr),s}setData(e){this.Pu,this.ae.bh(),this.Gg.Jg(this.ae,e),this.Qg(`full`)}update(e,t=!1){this.ae.bh(),this.Gg.tb(this.ae,e,t),this.Qg(`update`)}pop(e=1){let t=this.Gg.ib(this.ae,e);t.length!==0&&this.Qg(`update`);let n=eD(this.seriesType());return t.map((e=>n(e)))}dataByIndex(e,t){let n=this.ae.Un().Hn(e,t);return n===null?null:eD(this.seriesType())(n)}data(){let e=eD(this.seriesType());return this.ae.Un().Bh().map((t=>e(t)))}subscribeDataChanged(e){this.Kg.i(e)}unsubscribeDataChanged(e){this.Kg._(e)}applyOptions(e){this.ae.vr(e)}options(){return NS(this.ae.N())}priceScale(){return this.Zg.priceScale(this.ae.Ft().pl(),this.getPane().paneIndex())}createPriceLine(e){let t=OS(NS(uD),e);return new dD(this.ae.Ea(t))}removePriceLine(e){this.ae.Aa(e.Yg())}priceLines(){return this.ae.La().map((e=>new dD(e)))}seriesType(){return this.ae.bh()}lastValueData(e){let t=this.ae.Ae(e);return t.Le?{noData:!0}:{noData:!1,price:t.Mt,color:t.R}}attachPrimitive(e){this.ae.ol(e),e.attached&&e.attached({chart:this.qg,series:this,requestUpdate:()=>this.ae.Qt().ka(),horzScaleBehavior:this.Pu})}detachPrimitive(e){this.ae._l(e),e.detached&&e.detached(),this.ae.Qt().ka()}getPane(){let e=this.ae,t=$(this.ae.Qt().Ks(e));return this.Xg(t)}moveToPane(e){this.ae.Qt().rf(this.ae,e)}seriesOrder(){let e=this.ae.Qt().Ks(this.ae);return e===null?-1:e.Y_().indexOf(this.ae)}setSeriesOrder(e){let t=this.ae.Qt().Ks(this.ae);t!==null&&t.vu(this.ae,e)}Qg(e){this.Kg.v()&&this.Kg.p(e)}},pD=class{constructor(e,t,n){this.nb=new DS,this.Qu=new DS,this.Nw=new DS,this.sn=e,this.ia=e.Et(),this.vM=t,this.ia.Zc().i(this.sb.bind(this)),this.ia.Xc().i(this.eb.bind(this)),this.vM.qw().i(this.rb.bind(this)),this.Pu=n}m(){this.ia.Zc().u(this),this.ia.Xc().u(this),this.vM.qw().u(this),this.nb.m(),this.Qu.m(),this.Nw.m()}scrollPosition(){return this.ia.Oc()}scrollToPosition(e,t){t?this.ia.Yc(e,1e3):this.sn.gs(e)}scrollToRealTime(){this.ia.qc()}getVisibleRange(){let e=this.ia.xc();return e===null?null:{from:e.from.originalTime,to:e.to.originalTime}}setVisibleRange(e){let t={from:this.Pu.convertHorzItemToInternal(e.from),to:this.Pu.convertHorzItemToInternal(e.to)},n=this.ia.kc(t);this.sn.sf(n)}getVisibleLogicalRange(){let e=this.ia.Sc();return e===null?null:{from:e.Na(),to:e.bi()}}setVisibleLogicalRange(e){wS(e.from<=e.to,`The from index cannot be after the to index.`),this.sn.sf(e)}resetTimeScale(){this.sn.ws()}fitContent(){this.sn.td()}logicalToCoordinate(e){let t=this.sn.Et();return t.Zi()?null:t.jt(e)}coordinateToLogical(e){return this.ia.Zi()?null:this.ia.Vc(e)}timeToIndex(e,t){let n=this.Pu.convertHorzItemToInternal(e);return this.ia.Mc(n,t)}timeToCoordinate(e){let t=this.timeToIndex(e,!1);return t===null?null:this.ia.jt(t)}coordinateToTime(e){let t=this.sn.Et(),n=t.Vc(e),r=t.en(n);return r===null?null:r.originalTime}width(){return this.vM.pv().width}height(){return this.vM.pv().height}subscribeVisibleTimeRangeChange(e){this.nb.i(e)}unsubscribeVisibleTimeRangeChange(e){this.nb._(e)}subscribeVisibleLogicalRangeChange(e){this.Qu.i(e)}unsubscribeVisibleLogicalRangeChange(e){this.Qu._(e)}subscribeSizeChange(e){this.Nw.i(e)}unsubscribeSizeChange(e){this.Nw._(e)}applyOptions(e){this.ia.vr(e)}options(){return{...NS(this.ia.N()),barSpacing:this.ia.ml()}}sb(){this.nb.v()&&this.nb.p(this.getVisibleRange())}eb(){this.Qu.v()&&this.Qu.p(this.getVisibleLogicalRange())}rb(e){this.Nw.p(e.width,e.height)}};function mD(e){return function(e){if(MS(e.handleScale)){let t=e.handleScale;e.handleScale={axisDoubleClickReset:{time:t,price:t},axisPressedMouseMove:{time:t,price:t},mouseWheel:t,pinch:t}}else if(e.handleScale!==void 0){let{axisPressedMouseMove:t,axisDoubleClickReset:n}=e.handleScale;MS(t)&&(e.handleScale.axisPressedMouseMove={time:t,price:t}),MS(n)&&(e.handleScale.axisDoubleClickReset={time:n,price:n})}let t=e.handleScroll;MS(t)&&(e.handleScroll={horzTouchDrag:t,vertTouchDrag:t,mouseWheel:t,pressedMouseMove:t})}(e),e}var hD=class{constructor(e,t,n){this.hb=new Map,this.ab=new Map,this.lb=new DS,this.ob=new DS,this._b=new DS,this.dd=new WeakMap,this.ub=new EE(t);let r=n===void 0?NS(sD()):OS(NS(sD()),mD(n));this.cb=t,this.hv=new lE(e,r,t),this.hv.mw().i((e=>{this.lb.v()&&this.lb.p(this.fb(e()))}),this),this.hv.ww().i((e=>{this.ob.v()&&this.ob.p(this.fb(e()))}),this),this.hv.Bd().i((e=>{this._b.v()&&this._b.p(this.fb(e()))}),this);let i=this.hv.Qt();this.pb=new pD(i,this.hv.bM(),this.cb)}remove(){this.hv.mw().u(this),this.hv.ww().u(this),this.hv.Bd().u(this),this.pb.m(),this.hv.m(),this.hb.clear(),this.ab.clear(),this.lb.m(),this.ob.m(),this._b.m(),this.ub.m()}resize(e,t,n){this.autoSizeActive()||this.hv.wM(e,t,n)}addCustomSeries(e,t={},n=0){let r=(e=>({type:`Custom`,isBuiltIn:!1,defaultOptions:{...GE,...e.defaultOptions()},mb:KE,wb:e}))(ES(e));return this.Mb(r,t,n)}addSeries(e,t={},n=0){return this.Mb(e,t,n)}removeSeries(e){let t=TS(this.hb.get(e)),n=this.ub.if(t);this.hv.Qt().if(t),this.gb(n),this.hb.delete(e),this.ab.delete(t)}Jg(e,t){this.gb(this.ub.og(e,t))}tb(e,t,n){this.gb(this.ub.pg(e,t,n))}ib(e,t){let[n,r]=this.ub.wg(e,t);return n.length!==0&&this.gb(r),n}subscribeClick(e){this.lb.i(e)}unsubscribeClick(e){this.lb._(e)}subscribeCrosshairMove(e){this._b.i(e)}unsubscribeCrosshairMove(e){this._b._(e)}subscribeDblClick(e){this.ob.i(e)}unsubscribeDblClick(e){this.ob._(e)}priceScale(e,t=0){return new cD(this.hv,e,t)}timeScale(){return this.pb}applyOptions(e){this.hv.vr(mD(e))}options(){return this.hv.N()}takeScreenshot(e=!1,t=!1){let n,r;try{t||(n=this.hv.Qt().N().crosshair.mode,this.hv.vr({crosshair:{mode:2}})),r=this.hv.TM(e)}finally{t||n===void 0||this.hv.Qt().vr({crosshair:{mode:n}})}return r}addPane(e=!1){let t=this.hv.Qt().uf();return t.j_(e),this.bb(t)}removePane(e){this.hv.Qt().Ad(e)}swapPanes(e,t){this.hv.Qt().zd(e,t)}autoSizeActive(){return this.hv.CM()}chartElement(){return this.hv.Mv()}panes(){return this.hv.Qt().Gn().map((e=>this.bb(e)))}paneSize(e=0){let t=this.hv.AM(e);return{height:t.height,width:t.width}}setCrosshairPosition(e,t,n){let r=this.hb.get(n);if(r===void 0)return;let i=this.hv.Qt().Ks(r);i!==null&&this.hv.Qt().Gd(e,t,i)}clearCrosshairPosition(){this.hv.Qt().Zd(!0)}horzBehaviour(){return this.cb}Mb(e,t={},n=0){wS(e.mb!==void 0),function(e){if(e===void 0||e.type===`custom`)return;let t=e;t.minMove!==void 0&&t.precision===void 0&&(t.precision=oT(t.minMove))}(t.priceFormat),e.type===`Candlestick`&&function(e){e.borderColor!==void 0&&(e.borderUpColor=e.borderColor,e.borderDownColor=e.borderColor),e.wickColor!==void 0&&(e.wickUpColor=e.wickColor,e.wickDownColor=e.wickColor)}(t);let r=OS(NS(yS),NS(e.defaultOptions),t),i=e.mb,a=new fw(this.hv.Qt(),e.type,r,i,e.wb);this.hv.Qt().Qd(a,n);let o=new fD(a,this,this,this,this.cb,(e=>this.bb(e)));return this.hb.set(o,a),this.ab.set(a,o),o}gb(e){let t=this.hv.Qt();for(let t of e.Y_.keys())t.Ia();t.Xd(e.Et.Dc,e.Et.Sg,e.Et.xg),e.Y_.forEach(((e,t)=>t.ht(e.ue,e.bg))),t.Et().dc(),t.Lc()}Sb(e){return TS(this.ab.get(e))}xb(e){return e!==void 0&&this.ab.has(e)?this.Sb(e):void 0}fb(e){let t=new Map;e.QM.forEach(((e,n)=>{let r=n.bh(),i=eD(r)(e);if(r!==`Custom`)wS(fE(i));else{let e=n.cl();wS(!e||!1===e(i))}t.set(this.Sb(n),i)}));let n=this.xb(e.jM),r=e.YM===void 0?void 0:{type:e.YM.ds,sourceKind:e.YM.KM,objectKind:e.YM.GM,series:this.xb(e.YM.Y_),objectId:e.YM.ZM,paneIndex:e.YM.XM};return{time:e.Qr,logical:e.$n,point:e.JM,paneIndex:e.XM,hoveredInfo:r,hoveredSeries:n,hoveredObjectId:e.qM,seriesData:t,sourceEvent:e.tg}}bb(e){let t=this.dd.get(e);return t||(t=new lD(this.hv,(e=>this.Sb(e)),e,this),this.dd.set(e,t)),t}};function gD(e){if(jS(e)){let t=document.getElementById(e);return wS(t!==null,`Cannot find element in DOM with id=${e}`),t}return e}function _D(e,t,n){let r=new hD(gD(e),t,n);return t.setOptions(r.options()),r}function vD(e,t){return _D(e,new wT,wT.Tf(t))}var yD=class extends BE{constructor(e,t){super(e,t,!0)}Og(e,t,n){t.Ic(this.kg,FS(this.Tg)),e.Jo(this.kg,n,FS(this.Tg))}Tb(e,t){return{wt:e,Mt:t,_t:NaN,ut:NaN}}Lg(){let e=this.ae.Sa();this.kg=this.ae.Ua().Bh().map((t=>{let n;if((t.Gr??1)>1){let e=t.Wt[1],r=t.Wt[2],i=t.Wt[3];n=Math.abs(e-i)>Math.abs(r-i)?e:r}else n=t.Wt[3];return this.Rb(t.$n,n,e)}))}},bD=class extends BE{constructor(e,t){super(e,t,!1)}Bg(e,t){return IE(this.kg,this.Tg,e,t,this.le.Et().ml(),this.ae.N().hitTestTolerance,((e,t)=>{t[0]=e.n_,t[1]=e.s_}))}Og(e,t,n){t.Ic(this.kg,FS(this.Tg)),e.t_(this.kg,n,FS(this.Tg))}fS(e,t,n){return{wt:e,jr:t.Wt[0],qr:t.Wt[1],Yr:t.Wt[2],Kr:t.Wt[3],_t:NaN,i_:NaN,n_:NaN,s_:NaN,e_:NaN}}Lg(){let e=this.ae.Sa();this.kg=this.ae.Ua().Bh().map((t=>this.Rb(t.$n,t,e)))}},xD=class extends US{constructor(){super(...arguments),this.qt=null,this.oS=0}ht(e){this.qt=e}et(e){if(this.qt===null||this.qt.Un.length===0||this.qt.lt===null)return;let{horizontalPixelRatio:t}=e;this.oS=function(e,t){if(e>=2.5&&e<=4)return Math.floor(3*t);let n=1-.2*Math.atan(Math.max(4,e)-4)/(.5*Math.PI),r=Math.floor(e*n*t),i=Math.floor(e*t);return Math.max(Math.floor(t),Math.min(r,i))}(this.qt.ml,t),this.oS>=2&&Math.floor(t)%2!=this.oS%2&&this.oS--;let n=this.qt.Un;this.qt.pS&&this.vS(e,n,this.qt.lt),this.qt.gi&&this.Vm(e,n,this.qt.lt);let r=this.mS(t);(!this.qt.gi||this.oS>2*r)&&this.wS(e,n,this.qt.lt)}vS(e,t,n){if(this.qt===null)return;let{context:r,horizontalPixelRatio:i,verticalPixelRatio:a}=e,o=``,s=Math.min(Math.floor(i),Math.floor(this.qt.ml*i));s=Math.max(Math.floor(i),Math.min(s,this.oS));let c=Math.floor(.5*s),l=null;for(let e=n.from;e<n.to;e++){let n=t[e];n.rh!==o&&(r.fillStyle=n.rh,o=n.rh);let u=Math.round(Math.min(n.i_,n.e_)*a),d=Math.round(Math.max(n.i_,n.e_)*a),f=Math.round(n.n_*a),p=Math.round(n.s_*a),m=Math.round(i*n._t)-c,h=m+s-1;l!==null&&(m=Math.max(l+1,m),m=Math.min(m,h));let g=h-m+1;r.fillRect(m,f,g,u-f),r.fillRect(m,d+1,g,p-d),l=h}}mS(e){let t=Math.floor(1*e);this.oS<=2*t&&(t=Math.floor(.5*(this.oS-1)));let n=Math.max(Math.floor(e),t);return this.oS<=2*n?Math.max(Math.floor(e),Math.floor(1*e)):n}Vm(e,t,n){if(this.qt===null)return;let{context:r,horizontalPixelRatio:i,verticalPixelRatio:a}=e,o=``,s=this.mS(i),c=null;for(let e=n.from;e<n.to;e++){let n=t[e];n.eh!==o&&(r.fillStyle=n.eh,o=n.eh);let l=Math.round(n._t*i)-Math.floor(.5*this.oS),u=l+this.oS-1,d=Math.round(Math.min(n.i_,n.e_)*a),f=Math.round(Math.max(n.i_,n.e_)*a);if(c!==null&&(l=Math.max(c+1,l),l=Math.min(l,u)),this.qt.ml*i>2*s)XS(r,l,d,u-l+1,f-d+1,s);else{let e=u-l+1;r.fillRect(l,d,e,f-d+1)}c=u}}wS(e,t,n){if(this.qt===null)return;let{context:r,horizontalPixelRatio:i,verticalPixelRatio:a}=e,o=``,s=this.mS(i);for(let e=n.from;e<n.to;e++){let n=t[e],c=Math.round(Math.min(n.i_,n.e_)*a),l=Math.round(Math.max(n.i_,n.e_)*a),u=Math.round(n._t*i)-Math.floor(.5*this.oS),d=u+this.oS-1;if(n.sh!==o){let e=n.sh;r.fillStyle=e,o=e}this.qt.gi&&(u+=s,c+=s,d-=s,l-=s),c>l||r.fillRect(u,c,d-u+1,l-c+1)}}},SD=class extends bD{constructor(){super(...arguments),this.Vg=new xD}Rb(e,t,n){return{...this.fS(e,t,n),...n.Sh(e)}}Ng(){let e=this.ae.N();this.Vg.ht({Un:this.kg,ml:this.le.Et().ml(),pS:e.wickVisible,gi:e.borderVisible,lt:this.Tg})}},CD={type:`Candlestick`,isBuiltIn:!0,defaultOptions:{upColor:`#26a69a`,downColor:`#ef5350`,wickVisible:!0,borderVisible:!0,borderColor:`#378658`,borderUpColor:`#26a69a`,borderDownColor:`#ef5350`,wickColor:`#737375`,wickUpColor:`#26a69a`,wickDownColor:`#ef5350`},mb:(e,t)=>new SD(e,t)},wD=class extends US{constructor(){super(...arguments),this.qt=null,this.MS=[]}ht(e){this.qt=e,this.MS=[]}et({context:e,horizontalPixelRatio:t,verticalPixelRatio:n}){if(this.qt===null||this.qt.ot.length===0||this.qt.lt===null)return;this.MS.length||this.gS(t);let r=Math.max(1,Math.floor(n)),i=Math.round(this.qt.bS*n)-Math.floor(r/2),a=i+r;for(let t=this.qt.lt.from;t<this.qt.lt.to;t++){let o=this.qt.ot[t],s=this.MS[t-this.qt.lt.from],c=Math.round(o.ut*n),l,u;e.fillStyle=o.sh,c<=i?(l=c,u=a):(l=i,u=c-Math.floor(r/2)+r),e.fillRect(s.Na,l,s.bi-s.Na+1,u-l)}}gS(e){if(this.qt===null||this.qt.ot.length===0||this.qt.lt===null)return void(this.MS=[]);let t=Math.ceil(this.qt.ml*e)<=1?0:Math.max(1,Math.floor(e)),n=Math.round(this.qt.ml*e)-t;this.MS=Array(this.qt.lt.to-this.qt.lt.from);for(let t=this.qt.lt.from;t<this.qt.lt.to;t++){let r=this.qt.ot[t],i=Math.round(r._t*e),a,o;if(n%2){let e=(n-1)/2;a=i-e,o=i+e}else{let e=n/2;a=i-e,o=i+e-1}this.MS[t-this.qt.lt.from]={Na:a,bi:o,SS:i,ce:r._t*e,wt:r.wt}}for(let e=this.qt.lt.from+1;e<this.qt.lt.to;e++){let n=this.MS[e-this.qt.lt.from],r=this.MS[e-this.qt.lt.from-1];n.wt===r.wt+1&&n.Na-r.bi!==t+1&&(r.SS>r.ce?r.bi=n.Na-t-1:n.Na=r.bi+t+1)}let r=Math.ceil(this.qt.ml*e);for(let e=this.qt.lt.from;e<this.qt.lt.to;e++){let t=this.MS[e-this.qt.lt.from];t.bi<t.Na&&(t.bi=t.Na);let n=t.bi-t.Na+1;r=Math.min(n,r)}if(t>0&&r<4)for(let e=this.qt.lt.from;e<this.qt.lt.to;e++){let t=this.MS[e-this.qt.lt.from];t.bi-t.Na+1>r&&(t.SS>t.ce?--t.bi:t.Na+=1)}}},TD=class extends yD{constructor(){super(...arguments),this.Vg=new wD}Bg(e,t){let n=this.ae.Ft().Nt(this.ae.N().base,$(this.ae.Lt()).Wt);return n===null?null:IE(this.kg,this.Tg,e,t,this.le.Et().ml(),this.ae.N().hitTestTolerance,((e,t)=>{t[0]=e.ut,t[1]=n}))}Rb(e,t,n){return{...this.Tb(e,t),...n.Sh(e)}}Ng(){let e={ot:this.kg,ml:this.le.Et().ml(),lt:this.Tg,bS:this.ae.Ft().Nt(this.ae.N().base,$(this.ae.Lt()).Wt)};this.Vg.ht(e)}},ED={type:`Histogram`,isBuiltIn:!0,defaultOptions:{color:`#26a69a`,base:0},mb:(e,t)=>new TD(e,t)};({...yS});var DD={account:{name:`Name`,address:`Account address`,balances:`Balances`,noBalances:`No token balances were returned.`,nfts:`NFTs`,noNfts:`No NFTs in the scanned objects.`,noImage:`No image`,objectsTruncated:`Some objects beyond the scanned range are omitted.`},receipt:{success:`Transaction succeeded on Sui`,failure:`Transaction failed on Sui`,sender:`Sender`,account:`Affected account`,object:`Object`,noBalanceChanges:`No balance changes were recorded.`,gasComputation:`Computation cost`,gasStorage:`Storage cost`,gasRebate:`Storage rebate`,gasBudget:`Network fee limit (gas budget)`,netFeeExplanation:`The network fee shown above includes the storage rebate. If it is negative, the rebate exceeds the computation and storage charges.`,estimatedNetFeeExplanation:`The estimated network fee shown above includes the storage rebate. If it is negative, the rebate exceeds the estimated computation and storage charges.`,gasLimitExplanation:`The gas budget limits network fee spending. It is not an estimate of the amount charged.`,gasPrice:`Gas price`,gasPayment:`Gas payment object`,graph:`Transaction graph`,graphTip:`A diagram of this transaction's programmable transaction block (PTB), derived from public on-chain data. It is a diagnostic view only, not transaction input, signing, or a safety verdict.`,graphReviewTip:`A diagram of the transaction prepared for this review and simulation. It shows what is being reviewed, not an actual result, permission to sign, or a guarantee of safety.`,graphRendering:`Rendering the transaction graph…`,graphFailed:`The transaction graph could not be rendered`,graphZoomIn:`Zoom in`,graphZoomOut:`Zoom out`,graphCenter:`Center`,graphShowAddresses:`Show full addresses`,graphShowNames:`Show readable labels`,moveCalls:`Move calls`,noMoveCalls:`No Move calls were recorded.`,inputs:`Inputs`,noInputs:`No inputs were recorded.`,inputKinds:{object:`Owned object`,shared_object:`Shared object`,receiving:`Receiving object`,pure:`Pure value`,withdrawal:`Balance withdrawal`,unknown:`Input`},bytes:`bytes`,events:`Events`,noEvents:`No events were recorded.`,objectChanges:`Object changes`,noObjectChanges:`No object changes were recorded.`},chart:{boundaryUsdc:`Prices are in USDC, not USD; dollar parity is not guaranteed.`,boundaryScope:`Historical prices, not live quotes.`,source:`Source: DeepBookV3 Indexer.`,renderedWith:`Rendered with`,library:`TradingView Lightweight Charts`},common:{walletStatusRecovery:`Ask in chat to open Settings, then use Troubleshooting to restart the connection service. This does not confirm removal of a connection in your wallet app.`,mainnet:`Sui mainnet`,retrievedAt:`Data retrieved`}},OD={en:DD};function kD(){try{return(navigator.language||`en`).slice(0,2).toLowerCase()}catch{return`en`}}function AD(e=kD()){return OD[e]??DD}var jD=AD(),MD={source_unavailable:`Chart data is unavailable right now.`,source_timeout:`The chart data source did not respond in time.`,source_http_error:`The chart data source returned an error.`,official_indexer_invalid_payload:`The chart data source returned information that could not be used.`,missing_pool_name:`No trading pair was selected.`,unsupported_interval:`This candle interval is not supported.`,invalid_timestamp:`A start or end time could not be read.`,invalid_timestamp_window:`The start time must be before the end time.`,invalid_limit:`The requested number of candles is not valid.`,unsupported_query_field:`This chart request includes an unsupported option.`,duplicate_query_field:`This chart request repeats an option.`,limit_exceeds_chart_cap:`This chart request exceeds the candle limit.`,pool_not_in_official_usdc_pools:`This trading pair is not available in the supported USDC charts.`},ND=B({start:F(),timestampMs:I().int(),open:F(),high:F(),low:F(),close:F(),volume:F()}),PD=[`Latest 500`,`Last 24h`,`Last 7d`,`Last 30d`],FD=B({status:G(`ok`),pools:z(B({poolName:F(),baseAsset:B({symbol:F()})})),intervals:z(F()),defaultInterval:F(),defaultLimit:I().int().positive(),maxCandles:I().int().positive()}),ID=B({status:W([`ok`,`empty_result`]),candles:z(ND),candleCount:I().int().nonnegative(),query:B({poolName:F(),interval:F(),startTimeMs:I().int().nonnegative().optional(),endTimeMs:I().int().nonnegative().optional(),limit:I().int().positive()}),source:B({fetchedAt:F()}),pair:B({baseAsset:B({symbol:F()}),quoteAsset:B({symbol:G(`USDC`)})})}).refine(e=>e.candleCount===e.candles.length,`Candle count differs from returned rows.`),LD={title:`DeepBook USDC chart`,guidance:(e,t)=>t.recoveryNeeded?`Ask in chat for a new chart with the pair and time range you want.`:void 0,controls(e,t){let n=FD.parse(e.data),r=document.createElement(`form`);r.className=`ui-form`;let i=ig({choices:[{label:`Choose a pair`,value:``},...n.pools.map(e=>({label:`${e.baseAsset.symbol} / USDC`,value:e.poolName}))]});i.required=!0;let a=ig({choices:n.intervals.map(e=>({label:e,value:e}))});a.value=typeof e.input.interval==`string`?e.input.interval:n.defaultInterval;let o=ng({placeholder:`YYYY-MM-DDTHH:mm`}),s=ng({placeholder:`YYYY-MM-DDTHH:mm`});typeof e.input.startTimeMs==`number`&&(o.value=HD(e.input.startTimeMs)),typeof e.input.endTimeMs==`number`&&(s.value=HD(e.input.endTimeMs));let c=Number(e.input.limit??n.defaultLimit),l=ag(`Time range & interval`,e.input.startTimeMs!==void 0||e.input.endTimeMs!==void 0),u=$h(`p`,`ui-note`,zD(e.input));for(let e of[o,s])e.addEventListener(`input`,()=>{u.textContent=`Custom range · UTC`});let d=$h(`div`,`card-actions`);for(let e of PD){let t=eg(e===`Latest 500`?`Recent`:e,()=>{let t=BD(e,new Date);o.value=t.startInput,s.value=t.endInput,c=Number(t.limitInput),u.textContent=e===`Latest 500`?`Recent candles · UTC`:`${e} · UTC`,p()},`secondary`);d.append(t)}let f=$h(`p`,`ui-error`);f.setAttribute(`role`,`alert`),l.body.append(rg(`Candle interval`,a),d,u,rg(`Start (UTC)`,o),rg(`End (UTC)`,s)),r.append($h(`p`,`ui-note`,`Set the time range and interval before choosing a pair, if needed.`),rg(`Choose a pair to open the chart`,i),l.details,f);function p(){if(i.value)try{let e=VD(o.value),n=VD(s.value);if(e!==void 0&&n!==void 0&&e>=n)throw Error(`Start must precede end.`);t({poolName:i.value,interval:a.value,limit:c,...e===void 0?{}:{startTimeMs:e},...n===void 0?{}:{endTimeMs:n}})}catch(e){f.textContent=e instanceof Error?e.message:`Invalid chart input.`}}r.addEventListener(`submit`,e=>{e.preventDefault(),p()});for(let e of[i,a,o,s])e.addEventListener(`change`,p);return{node:r,selectionHint:`To retry, clear the pair with “Choose a pair”, then select your pair again. Your time range and interval are kept.`}},result(e){let t=ID.safeParse(e.data);if(!t.success){let t=e.data;if(t?.status===`source_unavailable`||t?.status===`unsupported_input`||t?.status===`unsupported_pool`||t?.status===`over_limit`){let e=typeof t.reason==`string`?t.reason:t.status,n=Object.hasOwn(MD,e)?MD[e]:`The requested chart could not be loaded.`,r=$h(`div`);r.append($h(`p`,`ui-note`,n),$h(`p`,`ui-note`,`Ask in chat for a new chart with the pair and time range you want.`));let i=ag(`Details`);return i.body.append($h(`p`,void 0,`Reported reason: ${e}`)),r.append(i.details),{node:r}}throw Error(`Chart data is incomplete.`)}let n=t.data,r=$h(`div`);r.append($h(`p`,`ui-note`,`${n.pair.baseAsset.symbol} / USDC · ${n.query.interval}`),$h(`p`,`ui-note`,zD(n.query)));let i=ag(`Details`),a=$h(`p`,`ui-note`,`${jD.common.retrievedAt}: `);a.append(og(n.source.fetchedAt)),i.body.append(a);let o=e=>e===void 0?`not specified`:Number.isFinite(new Date(e).getTime())?new Date(e).toISOString():Qh(e);i.body.append($h(`p`,void 0,`Start: ${o(n.query.startTimeMs)} · End: ${o(n.query.endTimeMs)}`)),n.candleCount>=n.query.limit&&r.append($h(`p`,`ui-note`,`This view is limited to ${n.query.limit} candles; the requested period may contain more.`));let s=$h(`p`,`ui-note`,`${jD.chart.boundaryUsdc} ${jD.chart.boundaryScope} ${jD.chart.source}`),c=tg(jD.chart.library,`https://www.tradingview.com/`);if(c.target=`_blank`,c.rel=`noopener noreferrer`,s.append(` ${jD.chart.renderedWith} `,c,`.`),n.candles.length===0)return i.body.append(s),r.append($h(`p`,`ui-note`,`No candles returned for this range.`),i.details),{node:r};let l=$h(`div`,`card-chart`),u=$h(`p`,`ui-note`),d=n.candles.at(-1),f=e=>`${Qh(e.start)} · Open ${e.open} · High ${e.high} · Low ${e.low} · Close ${e.close} · Volume ${e.volume}`;u.textContent=f(d),i.body.append(u,s),r.append(l,i.details);let p,m,h,g,_=!1,v=!1,y=0,b=0,ee=()=>{let e=getComputedStyle(document.documentElement),t=t=>e.getPropertyValue(t).trim();p?.applyOptions({layout:{background:{color:t(`--ui-surface`)},textColor:t(`--ui-text`)},grid:{vertLines:{color:t(`--ui-border`)},horzLines:{color:t(`--ui-border`)}}})},x=()=>{v||(v=!0,m?.disconnect(),h?.disconnect(),p?.remove(),g!==void 0&&cancelAnimationFrame(g))},te=()=>{if(v||!l.isConnected)return;let e=l.clientWidth,t=l.clientHeight;if(!(e<=0||t<=0||e===y&&t===b))try{if(p)p.resize(e,t);else{p=vD(l,{width:e,height:t,autoSize:!1,layout:{attributionLogo:!1},timeScale:{timeVisible:!0,secondsVisible:!1,minBarSpacing:0,lockVisibleTimeRangeOnResize:!0}});let r=p.addSeries(CD,{upColor:`#167752`,downColor:`#b44336`,borderVisible:!1,wickUpColor:`#167752`,wickDownColor:`#b44336`,priceFormat:{type:`price`,precision:6,minMove:1e-6}}),i=p.addSeries(ED,{priceFormat:{type:`volume`},priceScaleId:``},1),a=RD(n.candles,n.query);r.setData(a.prices),i.setData(a.volumes),p.panes()[0]?.setStretchFactor(3),p.panes()[1]?.setStretchFactor(1),a.range?p.timeScale().setVisibleRange(a.range):p.timeScale().fitContent();let o=new Map(n.candles.map(e=>[GD(e),e]));p.subscribeCrosshairMove(e=>{u.textContent=f((typeof e.time==`number`?o.get(e.time):void 0)??d)}),ee(),h=new MutationObserver(ee),h.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]})}y=e,b=t}catch{x(),l.replaceChildren($h(`p`,`ui-error`,`The chart could not be displayed. The saved query and source data are unchanged.`))}};return{node:r,mount:()=>{_||v||(_=!0,m=new ResizeObserver(()=>{v||g!==void 0||(g=requestAnimationFrame(()=>{g=void 0,te()}))}),m.observe(l),te())},dispose:x}}};function RD(e,t){let n=e.map(UD),r=e.map(WD),i=new Set(n.map(e=>e.time));for(let e of[t.startTimeMs,t.endTimeMs]){if(e===void 0)continue;let t=e/1e3;i.has(t)||(n.push({time:t}),r.push({time:t}),i.add(t))}n.sort((e,t)=>e.time-t.time),r.sort((e,t)=>e.time-t.time);let a=t.startTimeMs===void 0?n[0]?.time:t.startTimeMs/1e3,o=t.endTimeMs===void 0?n.at(-1)?.time:t.endTimeMs/1e3;return{prices:n,volumes:r,range:(t.startTimeMs!==void 0||t.endTimeMs!==void 0)&&a!==void 0&&o!==void 0&&a<o?{from:a,to:o}:void 0}}function zD(e){if(e.startTimeMs===void 0&&e.endTimeMs===void 0)return`Recent candles · UTC`;let t=e=>{if(e===void 0)return`not specified`;let t=new Date(e);return Number.isNaN(t.getTime())?`${e} milliseconds since 1970-01-01T00:00:00Z`:Qh(e)};return`Range (UTC): ${t(e.startTimeMs)} → ${t(e.endTimeMs)}`}function BD(e,t){if(e===`Latest 500`)return{startInput:``,endInput:``,limitInput:`500`};let n=e===`Last 24h`?864e5:e===`Last 7d`?6048e5:2592e6,r=t.getTime();return{startInput:HD(r-n),endInput:HD(r),limitInput:`10000`}}function VD(e){let t=e.trim();if(t===``)return;if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(t))throw Error(`UTC timestamps must use YYYY-MM-DDTHH:mm.`);let n=Date.parse(`${t}:00.000Z`);if(!Number.isSafeInteger(n))throw Error(`UTC timestamp is invalid.`);return n}function HD(e){return new Date(e).toISOString().slice(0,16)}function UD(e){return{time:GD(e),open:Number(e.open),high:Number(e.high),low:Number(e.low),close:Number(e.close)}}function WD(e){return{time:GD(e),value:Number(e.volume),color:Number(e.close)>=Number(e.open)?`rgba(22, 119, 82, 0.45)`:`rgba(180, 67, 54, 0.45)`}}function GD(e){return Math.floor(e.timestampMs/1e3)}cS(`chart`,LD);</script></body></html>
3812
+ `)),vv={0:`ED25519`,1:`Secp256k1`,2:`Secp256r1`,3:`MultiSig`,5:`ZkLogin`,6:`Passkey`},yv=e=>Object.freeze(e());function bv(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name===`Uint8Array`&&`BYTES_PER_ELEMENT`in e&&e.BYTES_PER_ELEMENT===1}function xv(e){if(!bv(e))throw TypeError(`Uint8Array expected`)}function Sv(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(e=>typeof e==`string`):t.every(e=>Number.isSafeInteger(e)):!1}function Cv(e){if(typeof e!=`function`)throw TypeError(`function expected`);return!0}function wv(e,t){if(typeof t!=`string`)throw TypeError(`${e}: string expected`);return!0}function Tv(e,t=`number`){if(typeof e!=`number`)throw TypeError(`${t}: expected number, got ${typeof e}`);if(!Number.isSafeInteger(e))throw RangeError(`${t}: expected safe integer, got ${e}`)}function Ev(e,t){if(!Sv(!1,t))throw TypeError(`${e}: array of numbers expected`)}var Dv=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function Ov(e,t=e.length){let n=Array(t);for(let r=0;r<t;r++)n[r]=e[r];return n}var kv=(()=>{try{let e=new TextDecoder;return e.decode(Uint8Array.of(65,48,43,127))===`A0+`?e:void 0}catch{return}})(),Av=8192;function jv(e){let t=e.length;if(kv!==void 0&&t>=12)return kv.decode(e);if(t<=Av)return String.fromCharCode.apply(null,e);let n=``;for(let r=0;r<t;r+=Av)n+=String.fromCharCode.apply(null,e.subarray(r,r+Av));return n}function Mv(e){if(Tv(e),e<=0||e>8)throw RangeError(`radix2: bits should be in (0..8]`);let t=Dv[e]-1;return{encode:n=>{xv(n);let r=n.length,i=new Uint8Array(Math.ceil(r*8/e)),a=0,o=0,s=0;for(let c=0;c<r;)for(c+2<r?(a=a<<24|n[c]<<16|n[c+1]<<8|n[c+2],o+=24,c+=3):(a=(a<<8|n[c])&65535,o+=8,c++);o-=e,i[s++]=a>>o&t,!(o<e););return o>0&&(i[s]=a<<e-o&t),i},decode:t=>{let n=t.length,r=new Uint8Array(Math.floor(n*e/8)),i=0,a=0,o=0;for(let s=0;s<n;s++)for(i=(i<<e|t[s])&65535,a+=e;a>=8;a-=8)r[o++]=i>>a-8&255;if(i=i<<8-a&255,a>=e)throw Error(`Excess padding`);if(i>0)throw Error(`Non-zero padding: ${i}`);return r}}}function Nv(e,t){let n=e.length;if(n>128)throw Error(`alphabet: max 128 letters`);let r=new Uint8Array(n),i=new Int8Array(128).fill(-1);for(let t=0;t<n;t++){let n=e.charCodeAt(t);if(e.codePointAt(t)!==n||n>127)throw Error(`alphabet: single-char ASCII letters only`);r[t]=n,i[n]=t}if(t!==void 0)for(let e of Object.keys(t)){let n=e.charCodeAt(0),r=i[t[e].charCodeAt(0)];if(e.length!==1||n>127||r===void 0||r===-1)throw Error(`alphabet: invalid alias ${e}`);i[n]=r}return{encode:e=>{let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++){let i=e[n],a=r[i];if(a===void 0)throw Error(`alphabet.encode: invalid digit ${i}`);t[n]=a}return jv(t)},decode:t=>{wv(`decode`,t);let n=t.length,r=new Uint8Array(n);for(let a=0;a<n;a++){let n=t.charCodeAt(a),o=n<128?i[n]:-1;if(o===-1)throw Error(`Unknown letter "${t[a]}". Allowed: ${e}`);r[a]=o}return r}}}function Pv(e){return Cv(e),function(...t){try{return e.apply(null,t)}catch{}}}var Fv=Nv(`qpzry9x8gf2tvdw0s3jn54khce6mua7l`),Iv=/^[\x21-\x60\x7b-\x7e]+$/;function Lv(e,t){for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);if(r<33||r>126)throw Error(`${e}: printable ASCII expected`)}}function Rv(e){let t=e.length,n=new Uint8Array(t);for(let r=0;r<t;r++){let t=e[r];if(t<0||t>=32)throw Error(`alphabet.encode: invalid digit ${t}`);n[r]=t}return n}var zv=[996825010,642813549,513874426,1027748829,705979059];function Bv(e){let t=e>>25,n=(e&33554431)<<5;for(let e=0;e<zv.length;e++)(t>>e&1)==1&&(n^=zv[e]);return n}function Vv(e,t,n=1){let r=e.length,i=1;for(let t=0;t<r;t++){let n=e.charCodeAt(t);if(n<33||n>126)throw Error(`Invalid prefix (${e})`);i=Bv(i)^n>>5}i=Bv(i);for(let t=0;t<r;t++)i=Bv(i)^e.charCodeAt(t)&31;for(let e of t)i=Bv(i)^e;for(let e=0;e<6;e++)i=Bv(i);i^=n;let a=new Uint8Array(6);for(let e=0;e<6;e++)a[e]=i>>>5*(5-e)&31;return Fv.encode(a)}function Hv(e){let t=e===`bech32`?1:734539939,n=Mv(5),r=e=>{xv(e);let t=e.length,n=Array(Math.ceil(t*8/5)),r=0,i=0,a=0;for(let o=0;o<t;o++)for(r=r<<8|e[o],i+=8;i>=5;i-=5)n[a++]=r>>i-5&31;return i>0&&(n[a]=r<<5-i&31),n},i=e=>{Ev(`radix2.decode`,e);let t=e.length,r=new Uint8Array(t);for(let n=0;n<t;n++){let t=e[n];if(t<0||t>=32)throw Error(`convertRadix2: invalid word=${t}`);r[n]=t}return n.decode(r)},a=Pv(i);function o(e,n,r=90){wv(`bech32.encode prefix`,e),r!==!1&&Tv(r,`limit`),bv(n)&&(n=Ov(n)),Ev(`bech32.encode`,n);let i=e.length;if(i===0)throw TypeError(`Invalid prefix length ${i}`);let a=i+7+n.length;if(r!==!1&&a>r)throw TypeError(`Length ${a} exceeds limit ${r}`);Lv(`bech32.encode prefix`,e);let o=e.toLowerCase(),s=Vv(o,n,t);return`${o}1${Fv.encode(Rv(n))}${s}`}function s(e,n=90){wv(`bech32.decode input`,e),n!==!1&&Tv(n,`limit`);let r=e.length;if(r<8||n!==!1&&r>n)throw TypeError(`invalid string length ${r}, expected (8..${n})`);let i=e.toLowerCase();if(e!==i&&!Iv.test(e))throw Lv(`bech32.decode input`,e),Error(`mixed-case string not allowed`);let a=i.lastIndexOf(`1`);if(a===0||a===-1)throw Error(`invalid separator "1"`);let o=i.slice(0,a),s=i.slice(a+1);if(s.length<6)throw Error(`invalid data length`);let c=Fv.decode(s),l=Ov(c,c.length-6),u=Vv(o,l,t);if(!s.endsWith(u))throw Error(`Invalid checksum in ${e}`);return{prefix:o,words:l}}let c=Pv(s);function l(e,t=90){let{prefix:n,words:r}=s(e,t);return{prefix:n,words:r,bytes:i(r)}}function u(e,t){return o(e,r(t))}return{encode:o,decode:s,encodeFromBytes:u,decodeToBytes:l,decodeUnsafe:c,fromWords:i,fromWordsUnsafe:a,toWords:r}}var Uv=yv(()=>Hv(`bech32`));function Wv(e){let{prefix:t,words:n}=Uv.decode(e);if(t!==`suiprivkey`)throw Error(`invalid private key prefix`);let r=new Uint8Array(Uv.fromWords(n)),i=r.slice(1);return{scheme:vv[r[0]],secretKey:i}}var Gv=`external-proposal-alpha-2026-05-25`,Kv=`proposal-review-model-alpha-2026-05-25`,qv=F().refine(e=>{let t=new Date(e);return!Number.isNaN(t.getTime())&&t.toISOString()===e},`Expected ISO 8601 UTC timestamp`),Jv=/transaction\s*bytes?|transactionBytes|tx\s*bytes?|serialized\s*transaction|serializedTransaction|signed\s*transaction|signing\s*request|signingRequest|wallet\s*authorization|walletAuthorization|private\s*key|privateKey|secret\s*key|secretKey|seed\s*phrase|mnemonic|suiprivkey|signature|route[-_\s]*selected|routeSelectedPlan|bcs\s*transaction|programmable\s*transaction/i,Yv=/(?:0x[0-9a-fA-F]{160,}|[A-Za-z0-9+/_=-]{160,})/,Xv=/suiprivkey1[023456789acdefghjklmnpqrstuvwxyz]+/gi,Zv=/(^|[^0-9a-fA-F])(?:0x)?[0-9a-fA-F]{64}($|[^0-9a-fA-F])/,Qv=/(^|[^A-Za-z0-9+/_=-])(?:[A-Za-z0-9+/]{43}=|[A-Za-z0-9+/]{44}|[A-Za-z0-9_-]{43,44})($|[^A-Za-z0-9+/_=-])/,$v=/^(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$/,ey=[12,15,18,21,24];function ty(e,t,n={}){return F().min(1).max(e).superRefine((e,r)=>{(Jv.test(e)||Yv.test(e)||ry(e)||iy(e)||!n.allowRawSecretLikeText&&ay(e))&&r.addIssue({code:`custom`,message:`${t} must not contain executable, signing, private-key, mnemonic, route-selected, or encoded secret-like material`})})}function ny(e,t){return ty(e,t,{allowRawSecretLikeText:!0})}function ry(e){return(e.match(Xv)??[]).some(e=>{try{return Wv(e.toLowerCase()),!0}catch{return e.toLowerCase().startsWith(`suiprivkey1`)}})}function iy(e){let t=e.normalize(`NFKD`).toLowerCase().replace(/[^a-z]+/g,` `).trim().split(/\s+/).filter(Boolean);for(let e of ey)if(!(t.length<e)){for(let n=0;n<=t.length-e;n+=1)if(gv(t.slice(n,n+e).join(` `),_v))return!0}return!1}function ay(e){return Zv.test(e)||Qv.test(e)}var oy=ty(80,`amountDisplay`).refine(e=>$v.test(e)&&/[1-9]/.test(e),{message:`Expected a positive decimal display amount`}),sy=B({kind:W([`mcp_server`,`ai_client`,`user`,`other`]),name:ty(120,`source.name`),reference:ty(256,`source.reference`).optional()}).strict(),cy=B({address:d_.optional(),label:ty(120,`party.label`).optional()}).strict().refine(e=>e.address!==void 0||e.label!==void 0,{message:`Expected address or label`}),ly=B({amountDisplay:oy,amountKind:G(`display_proposal`).default(`display_proposal`),symbol:ty(64,`amount.symbol`).optional(),coinType:ny(512,`amount.coinType`).optional(),denomination:ty(64,`amount.denomination`).optional()}).strict(),uy=B({packageId:ny(128,`action.target.packageId`).optional(),module:ty(128,`action.target.module`).optional(),function:ty(128,`action.target.function`).optional(),objectId:ny(128,`action.target.objectId`).optional(),label:ty(120,`action.target.label`).optional()}).strict().refine(e=>e.packageId!==void 0||e.module!==void 0||e.function!==void 0||e.objectId!==void 0||e.label!==void 0,{message:`Expected at least one action target field`}),dy=B({direction:W([`outgoing`,`expected_incoming`,`fee`]),amount:ly,recipient:cy.optional(),description:ty(512,`assetFlow.description`).optional()}).strict(),fy=B({id:ty(120,`proposal.id`),source:sy,network:G(`sui:mainnet`),createdAt:qv,expiresAt:qv.optional(),purpose:ty(512,`purpose`),assumptions:z(ty(512,`assumptions[]`)).max(20).optional(),requiredUserChoices:z(ty(512,`requiredUserChoices[]`)).max(20).optional()}).strict(),py=hc(`type`,[fy.extend({type:G(`payment`),payment:B({amount:ly,recipient:cy,target:ty(512,`payment.target`).optional()}).strict()}).strict(),fy.extend({type:G(`sui_action`),action:B({actionKind:ty(120,`action.actionKind`),target:uy,recipient:cy.optional(),assetFlow:z(dy).max(20).optional()}).strict()}).strict()]),my=B({id:F(),label:F(),status:W([`pass`,`warning`,`fail`]),message:F(),source:W([`proposal`,`adapter`,`registry`,`quote`,`wallet`,`simulation`,`network`])}).strict(),hy=B({id:F(),label:F(),reason:F()}).strict(),gy=B({modelVersion:G(Kv),contractVersion:G(Gv),proposalId:F(),proposalType:W([`payment`,`sui_action`]),proposalSource:sy,proposedAction:B({kind:W([`payment`,`sui_action`]),title:F(),purpose:F(),network:G(`sui:mainnet`),recipient:cy.optional(),target:H([F(),uy]).optional()}).strict(),assetFlow:B({outgoing:z(ly),expectedIncoming:z(ly),fees:z(ly)}).strict(),recipients:z(cy),targets:z(H([F(),uy])),evidenceUsed:z(B({id:F(),label:F(),source:W([`external_proposal`,`local_schema`]),summary:F()}).strict()),missingEvidence:z(hy),requiredUserChoices:z(hy),unsupportedClaims:z(B({id:F(),label:F(),reason:F()}).strict()),rejectedExecutableFields:z(B({fieldName:F(),reason:F()}).strict()),freshness:B({proposalCreatedAt:qv,proposalExpiresAt:qv.optional(),evaluatedAt:qv,status:W([`current`,`expired`,`created_in_future`,`expiry_not_provided`]),reason:F()}).strict(),blockingChecks:z(my),nonSignableReason:B({code:G(`external_proposal_review_only`),message:F(),blockedCapabilities:z(F())}).strict()}).strict();B({requestedIntent:py,implementationStatus:G(`read_only_review_only`),contractVersion:G(Gv)}).strict();var _y=[`adapter_not_implemented`,`producer_stage_missing`,`wallet_review_contract_emit_missing`,`network_mismatch`,`insufficient_balance`,`insufficient_gas`,`allowlist_violation`,`asset_mismatch`,`amount_mismatch`,`wallet_mismatch`,`unsupported_action`,`object_resolution_failed`,`proposal_review_only`],vy=[`review_evidence_stale`,`quote_stale`,`quote_unavailable`,`simulation_transient_failure`,`review_update_failed`,`wallet_connection_changed`],yy=[`proposed`,`awaiting_wallet`,`wallet_connected`,`ready_for_wallet_review`,`refresh_required`,`blocked`,`expired`],by=[`humanReadableReview`,`simulation`,`transactionReviewData`,`ptbVisualization`,`assetFlowActual`,`beforeAfterBalance`],xy=W([`client.core.simulateTransaction`,`client.transactionExecutionService.simulateTransaction`]),Sy=`ptb-visualization-contract-alpha-2026-05-25`,Cy=[`proposedAction`,`assetFlow`,`recipients`,`targets`,`evidenceUsed`,`missingEvidence`,`requiredUserChoices`,`unsupportedClaims`,`freshness`,`blockingChecks`],wy=[`effects`,`balanceChanges`,`objectTypes`,`transaction`],Ty=[`transaction_bytes`,`serialized_transaction`,`wallet_signature_request`,`private_key_material`,`wallet_authorization`,`signing_data`,`signing_readiness`,`payment_execution_readiness`],Ey=[`transaction_building_input`,`wallet_authorization`,`signing_data`,`signing_readiness`,`payment_execution_readiness`,`route_recommendation`],Dy=u_,Oy=`MIST`,ky=[`checkedAt`,`expiresAt`],Ay=[`checkedAt`,`expiryStatus`],jy=[`rawAmount`,`asset`,`amountRole`],My=[`minOutRaw`,`asset`,`amountRole`],Ny=[`gasBudgetRaw`,`asset`,`amountRole`],Py=[`gasUsedRaw`,`asset`,`amountRole`],Fy=[`checkedAt`,`gasResolutionStatus`,`unresolvedReason`],Iy=[`balanceChanges`,`asset`,`amountRole`],Ly=[`coinType`,`decimals`],Ry=[`quoteEvidenceId`,`minOutRaw`],zy=[`maxSlippageBps`,`userSelection`],By=[`maxSlippageBps`,`minOutRaw`],Vy=[`ownerAccount`,`objects`],Hy=[`pinned_sdk_registry`,`verified_mainnet_onchain_metadata`,`wallet_account_read`,`quote_evidence`,`review_time_simulation`,`validated_request_fact`,`user_explicit_choice`],Uy=[`input`,`expected_output`,`minimum_output`,`gas_budget`,`gas_used`,`fee`,`balance_delta`],Wy={input:{kinds:[`validated_request_fact`,`wallet_account_read`,`user_explicit_choice`],fields:jy},expected_output:{kinds:[`quote_evidence`,`review_time_simulation`],fields:jy},minimum_output:{kinds:[`quote_evidence`],fields:My},gas_budget:{kinds:[`review_time_simulation`],fields:Ny},gas_used:{kinds:[`review_time_simulation`],fields:Py},fee:{kinds:[`review_time_simulation`],fields:jy},balance_delta:{kinds:[`review_time_simulation`],fields:Iy}},Gy={pinned_sdk_metadata:{kinds:[`pinned_sdk_registry`],fields:Ly},verified_mainnet_onchain_metadata:{kinds:[`verified_mainnet_onchain_metadata`],fields:Ly}},Ky={user_explicit:{kinds:[`user_explicit_choice`],fields:zy},adapter_policy_from_quote_evidence:{kinds:[`quote_evidence`],fields:By}},qy={kinds:[`review_time_simulation`],fields:Fy},Jy={kinds:[`quote_evidence`],fields:Ry},Yy={kinds:[`validated_request_fact`],fields:ky},Xy={kinds:[`validated_request_fact`],fields:Ay},Zy={raw_quantity_amount:{byRole:Wy},unit_metadata:{bySource:Gy},gas_unresolved_status:qy,expiry_status:{current:Yy,expired:Yy,not_provided:Xy,not_applicable:Xy},quote_min_out:Jy,slippage_policy:{bySource:Ky},object_ownership:{kinds:[`wallet_account_read`],fields:Vy},simulation_result:{kinds:[`review_time_simulation`],fields:wy}},Qy={gasBudgetClaimId:{factKind:`raw_quantity_amount`,role:`gas_budget`,assetCoinType:Dy,rawUnit:Oy},gasUsedClaimId:{factKind:`raw_quantity_amount`,role:`gas_used`,assetCoinType:Dy,rawUnit:Oy},gasObjectOwnershipClaimId:{factKind:`object_ownership`,ownership:`owned_by_account`}},$y=F().refine(e=>{let t=new Date(e);return!Number.isNaN(t.getTime())&&t.toISOString()===e},`Expected ISO 8601 UTC timestamp`),eb=j_(`unsigned integer`),tb=F().regex(/^0x[0-9a-fA-F]{1,64}$/,{message:`Expected a Sui object id`}),nb=F().min(1).max(512).refine(e=>{try{return P_(e)===e}catch{return!1}},`Expected a normalized Sui struct tag coin type`),J=F().min(1).max(120),rb=B({symbol:F().min(1).max(64).optional(),coinType:nb}).strict(),ib=/transaction\s*bytes?|tx\s*bytes?|serialized\s*transaction|serializedTransaction|signed\s*transaction|signing\s*request|signingRequest|wallet\s*authorization|walletAuthorization|private\s*key|privateKey|secret\s*key|secretKey|seed\s*phrase|mnemonic|suiprivkey|signature|bcs\s*transaction/i,ab=/(?:0x[0-9a-fA-F]{160,}|[A-Za-z0-9+/_=-]{160,})/;function ob(e,t){return F().min(1).max(e).superRefine((e,n)=>{(ib.test(e)||ab.test(e))&&n.addIssue({code:`custom`,message:`${t} must not contain executable transaction, signing, private-key, mnemonic, or long encoded material`})})}function sb(e,t){let n=new Set(e);return t.filter(e=>!n.has(e))}function cb(e,t,n,r,i){let a=sb(t,n);a.length!==0&&e.addIssue({code:`custom`,path:r,message:`${i} must include ${a.join(`, `)}`})}function lb(e,t,n,r,i){cb(e,t,n,r,i)}function ub(e,t,n){e.addIssue({code:`custom`,path:t,message:`${n} must match referenced evidence claim`})}function Y(e,t,n,r,i){t!==n&&ub(e,r,i)}function db(e,t,n,r,i){let a=new Set(t),o=new Set(n);if(a.size!==o.size)ub(e,r,i);else for(let t of a)if(!o.has(t)){ub(e,r,i);return}}function fb(e,t,n,r,i){(t.symbol!==n.symbol||t.coinType!==n.coinType)&&ub(e,r,i)}function pb(e,t,n,r,i){try{P_(t.coinType)!==n&&ub(e,r,i)}catch{ub(e,r,i)}}var mb=B({kind:W([`natural_language_intent`,`external_proposal`,`mcp_action_request`,`local_review_request`]),sourceId:F().min(1).max(160),capturedAt:$y,authority:G(`untrusted_until_review_regenerates_and_verifies`),userSelectionSource:W([`user_explicit`,`prior_user_explicit_context`]).optional()}).strict(),hb=B({id:J,kind:W(Hy),network:G(`sui:mainnet`),source:F().min(1).max(240),verifiedAt:$y,fields:z(F().min(1).max(120)).min(1)}).strict(),gb=hc(`factKind`,[B({id:J,factKind:G(`raw_quantity_amount`),sourceEvidenceId:J,role:W(Uy),asset:rb,rawAmount:eb}).strict(),B({id:J,factKind:G(`unit_metadata`),sourceEvidenceId:J,source:W([`pinned_sdk_metadata`,`verified_mainnet_onchain_metadata`]),coinType:nb,decimals:I().int().min(0).max(255)}).strict(),B({id:J,factKind:G(`gas_unresolved_status`),sourceEvidenceId:J,checkedAt:$y,status:G(`unresolved`),reason:F().min(1).max(240)}).strict(),B({id:J,factKind:G(`expiry_status`),sourceEvidenceId:J,checkedAt:$y,status:W([`current`,`expired`,`not_provided`,`not_applicable`]),expiresAt:$y.optional(),reason:F().min(1).max(240).optional()}).strict(),B({id:J,factKind:G(`quote_min_out`),sourceEvidenceId:J,quoteEvidenceId:F().min(1).max(120),minOutRaw:eb}).strict(),B({id:J,factKind:G(`slippage_policy`),sourceEvidenceId:J,policySource:W([`user_explicit`,`adapter_policy_from_quote_evidence`]),maxSlippageBps:I().int().min(0).max(1e4),minOutRaw:eb.optional()}).strict(),B({id:J,factKind:G(`object_ownership`),sourceEvidenceId:J,objectId:tb,ownerAccount:d_,ownership:W([`owned_by_account`,`shared_object`,`immutable_or_package`,`not_owned_by_account`])}).strict(),B({id:J,factKind:G(`simulation_result`),sourceEvidenceId:J,provider:xy,checksEnabled:G(!0),simulatedAt:$y,status:W([`success`,`failed`,`unavailable`]),requiredFields:z(W(wy)).min(wy.length),missingFields:z(W(wy)).default([]),failureReason:F().min(1).max(240).optional()}).strict()]),_b=B({id:J,role:W(Uy),asset:rb,rawAmount:eb,unit:B({decimals:I().int().min(0).max(255),source:W([`pinned_sdk_metadata`,`verified_mainnet_onchain_metadata`]),sourceField:F().min(1).max(160),unitClaimId:J}).strict(),amountClaimId:J,displayOnly:B({amountDisplay:F().min(1).max(120),reason:G(`presentation_only_not_signing_input`)}).strict().optional()}).strict(),vb=B({objectId:tb,ownerAccount:d_,ownershipClaimId:J}).strict(),yb=B({source:G(`review_time_simulation`),checkedAt:$y,gasBudgetRaw:eb.optional(),gasBudgetClaimId:J.optional(),gasUsedRaw:eb.optional(),gasUsedClaimId:J.optional(),gasObjects:z(vb).optional(),unresolvedReason:F().min(1).max(240).optional(),unresolvedClaimId:J.optional()}).strict().superRefine((e,t)=>{let n=e.gasBudgetRaw!==void 0||e.gasUsedRaw!==void 0;!n&&e.unresolvedReason===void 0&&t.addIssue({code:`custom`,message:`Expected gas evidence or unresolvedReason`}),n&&e.unresolvedReason!==void 0&&t.addIssue({code:`custom`,path:[`unresolvedReason`],message:`Resolved gas quantities must not include unresolvedReason`}),e.gasBudgetRaw!==void 0&&e.gasBudgetClaimId===void 0&&t.addIssue({code:`custom`,path:[`gasBudgetClaimId`],message:`gasBudgetRaw requires gasBudgetClaimId`}),e.gasBudgetRaw===void 0&&e.gasBudgetClaimId!==void 0&&t.addIssue({code:`custom`,path:[`gasBudgetClaimId`],message:`gasBudgetClaimId requires gasBudgetRaw`}),e.gasUsedRaw!==void 0&&e.gasUsedClaimId===void 0&&t.addIssue({code:`custom`,path:[`gasUsedClaimId`],message:`gasUsedRaw requires gasUsedClaimId`}),e.gasUsedRaw===void 0&&e.gasUsedClaimId!==void 0&&t.addIssue({code:`custom`,path:[`gasUsedClaimId`],message:`gasUsedClaimId requires gasUsedRaw`}),e.unresolvedReason!==void 0&&e.unresolvedClaimId===void 0&&t.addIssue({code:`custom`,path:[`unresolvedClaimId`],message:`unresolvedReason requires unresolvedClaimId`}),e.unresolvedReason===void 0&&e.unresolvedClaimId!==void 0&&t.addIssue({code:`custom`,path:[`unresolvedClaimId`],message:`unresolvedClaimId requires unresolvedReason`})}),bb=hc(`status`,[B({checkedAt:$y,status:G(`current`),expiresAt:$y,evidenceClaimId:J}).strict(),B({checkedAt:$y,status:G(`expired`),expiresAt:$y,evidenceClaimId:J}).strict(),B({checkedAt:$y,status:G(`not_provided`),evidenceClaimId:J,reason:F().min(1).max(240),expiresAt:uc().optional()}).strict(),B({checkedAt:$y,status:G(`not_applicable`),evidenceClaimId:J,reason:F().min(1).max(240),expiresAt:uc().optional()}).strict()]).superRefine((e,t)=>{e.status===`current`&&Date.parse(e.expiresAt)<=Date.parse(e.checkedAt)&&t.addIssue({code:`custom`,path:[`expiresAt`],message:`Current expiry evidence requires expiresAt after checkedAt`}),e.status===`expired`&&Date.parse(e.expiresAt)>Date.parse(e.checkedAt)&&t.addIssue({code:`custom`,path:[`expiresAt`],message:`Expired expiry evidence requires expiresAt at or before checkedAt`})}),xb=B({status:W([`required_and_verified`,`not_required_for_action`,`missing`,`stale`]),quoteEvidenceId:F().min(1).max(120).optional(),quoteEvidenceClaimId:J.optional(),maxSlippageBps:I().int().min(0).max(1e4).optional(),minOutRaw:eb.optional(),policySource:W([`user_explicit`,`adapter_policy_from_quote_evidence`]).optional(),policyEvidenceClaimId:J.optional()}).strict().superRefine((e,t)=>{e.status===`required_and_verified`&&(e.quoteEvidenceId===void 0||e.quoteEvidenceClaimId===void 0||e.maxSlippageBps===void 0||e.minOutRaw===void 0||e.policySource===void 0||e.policyEvidenceClaimId===void 0)&&t.addIssue({code:`custom`,message:`Verified min-out evidence requires quoteEvidenceId, quoteEvidenceClaimId, maxSlippageBps, minOutRaw, policySource, and policyEvidenceClaimId`}),e.quoteEvidenceId!==void 0&&e.quoteEvidenceClaimId===void 0&&t.addIssue({code:`custom`,path:[`quoteEvidenceClaimId`],message:`quoteEvidenceId requires quoteEvidenceClaimId`}),e.quoteEvidenceId===void 0&&e.quoteEvidenceClaimId!==void 0&&t.addIssue({code:`custom`,path:[`quoteEvidenceClaimId`],message:`quoteEvidenceClaimId requires quoteEvidenceId`}),e.minOutRaw!==void 0&&e.quoteEvidenceClaimId===void 0&&t.addIssue({code:`custom`,path:[`quoteEvidenceClaimId`],message:`minOutRaw requires quoteEvidenceClaimId`}),e.maxSlippageBps!==void 0&&e.policySource===void 0&&t.addIssue({code:`custom`,path:[`policySource`],message:`maxSlippageBps requires policySource`}),e.policySource!==void 0&&e.policyEvidenceClaimId===void 0&&t.addIssue({code:`custom`,path:[`policyEvidenceClaimId`],message:`policySource requires policyEvidenceClaimId`}),e.policySource===void 0&&e.policyEvidenceClaimId!==void 0&&t.addIssue({code:`custom`,path:[`policyEvidenceClaimId`],message:`policyEvidenceClaimId requires policySource`})}),Sb=B({checkedAt:$y,ownerAccount:d_,objects:z(B({objectId:tb,role:W([`input_coin`,`gas_coin`,`protocol_object`,`shared_object`,`receiving_object`]),ownership:W([`owned_by_account`,`shared_object`,`immutable_or_package`,`not_owned_by_account`]),evidenceClaimId:J}).strict()).min(1)}).strict(),Cb=B({evidenceClaimId:J,transactionDigest:f_,provider:xy,checksEnabled:G(!0),simulatedAt:$y,status:W([`success`,`failed`,`unavailable`]),requiredFields:z(W(wy)).min(wy.length),missingFields:z(W(wy)).default([]),failureReason:F().min(1).max(240).optional()}).strict().refine(e=>e.status!==`success`||e.missingFields.length===0,{message:`Successful simulation evidence must not have missing required fields`}).refine(e=>wy.every(t=>e.requiredFields.includes(t)),{message:`Simulation evidence must include every required simulation field`}).refine(e=>e.status===`success`||e.failureReason!==void 0,{message:`Failed or unavailable simulation evidence requires failureReason`}).refine(e=>e.status!==`success`||e.failureReason===void 0,{message:`Successful simulation evidence must not include failureReason`}),wb=B({fields:z(W(Cy)).min(Cy.length),transactionDigest:f_,source:G(`review_model_or_adapter_equivalent`),purpose:G(`human_review_before_wallet_authorization`)}).strict().refine(e=>Cy.every(t=>e.fields.includes(t)),{message:`Human-readable review fields must include every required review field`}),Tb=B({runtimeStatus:G(`emitted_pre_handoff`),mcpAndReviewUiMayExpose:z(W([`human_readable_review`,`ptb_visualization_artifact`,`diagnostics`,`status_checks`])).min(1),prohibited:z(W(Ty)).min(1)}).strict().superRefine((e,t)=>{lb(t,e.prohibited,Ty,[`prohibited`],`prohibited`)}),Eb=B({schemaVersion:G(1),adapterId:F().min(1).max(120),protocol:F().min(1).max(120),actionKind:F().min(1).max(120),network:G(`sui:mainnet`),inputProvenance:mb,sourceReferences:z(hb).min(1),evidenceClaims:z(gb).min(1),rawQuantities:z(_b).min(1),gas:yb,expiry:bb,slippageOrMinOut:xb,objectOwnership:Sb,simulation:Cb,humanReadableReview:wb,outputBoundary:Tb,reviewedTransactionDigest:f_}).strict().superRefine((e,t)=>{let n=new Set,r=new Map,i=new Map;e.sourceReferences.forEach((e,a)=>{n.has(e.id)&&t.addIssue({code:`custom`,path:[`sourceReferences`,a,`id`],message:`sourceReferences id must be unique: ${e.id}`}),n.add(e.id),r.has(e.id)||(r.set(e.id,e),i.set(e.id,a))});let a=new Set,o=new Map,s=new Map;e.evidenceClaims.forEach((e,n)=>{a.has(e.id)&&t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`id`],message:`evidenceClaims id must be unique: ${e.id}`}),a.add(e.id),o.has(e.id)||(o.set(e.id,e),s.set(e.id,n))});let c=(e,n)=>{if(e===void 0)return;let i=r.get(e);if(i!==void 0)return i;t.addIssue({code:`custom`,path:n,message:`source evidence id must reference sourceReferences[].id: ${e}`})},l=(e,n,r,a)=>{if(e===void 0)return;let o=c(e,r);if(o===void 0)return;let s=i.get(e),l=s===void 0?r:[`sourceReferences`,s];n.kinds.includes(o.kind)||t.addIssue({code:`custom`,path:[...l,`kind`],message:`${a} source kind must be one of ${n.kinds.join(`, `)}`}),cb(t,o.fields,n.fields,[...l,`fields`],`${a} sourceReferences fields`)},u=(e,n,r,i)=>{if(e===void 0){t.addIssue({code:`custom`,path:r,message:`${i} must reference evidenceClaims[].id`});return}let a=o.get(e);if(a===void 0)t.addIssue({code:`custom`,path:r,message:`${i} must reference evidenceClaims[].id: ${e}`});else{if(a.factKind!==n){let a=s.get(e),o=a===void 0?r:[`evidenceClaims`,a,`factKind`];t.addIssue({code:`custom`,path:o,message:`${i} evidence claim factKind must be ${n}`})}return a}};if(e.evidenceClaims.forEach((e,n)=>{e.factKind===`raw_quantity_amount`&&l(e.sourceEvidenceId,Zy.raw_quantity_amount.byRole[e.role],[`evidenceClaims`,n,`sourceEvidenceId`],`evidenceClaims[${n}].raw_quantity_amount`),e.factKind===`unit_metadata`&&l(e.sourceEvidenceId,Zy.unit_metadata.bySource[e.source],[`evidenceClaims`,n,`sourceEvidenceId`],`evidenceClaims[${n}].unit_metadata`),e.factKind===`gas_unresolved_status`&&l(e.sourceEvidenceId,Zy.gas_unresolved_status,[`evidenceClaims`,n,`sourceEvidenceId`],`evidenceClaims[${n}].gas_unresolved_status`),e.factKind===`expiry_status`&&(l(e.sourceEvidenceId,Zy.expiry_status[e.status],[`evidenceClaims`,n,`sourceEvidenceId`],`evidenceClaims[${n}].expiry_status`),(e.status===`current`||e.status===`expired`)&&e.expiresAt===void 0&&t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`expiresAt`],message:`Current or expired expiry claim requires expiresAt`}),(e.status===`not_provided`||e.status===`not_applicable`)&&e.reason===void 0&&t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`reason`],message:`Unavailable expiry claim requires reason`}),(e.status===`not_provided`||e.status===`not_applicable`)&&e.expiresAt!==void 0&&t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`expiresAt`],message:`Unavailable expiry claim must not include expiresAt`}),e.status===`current`&&e.expiresAt!==void 0&&Date.parse(e.expiresAt)<=Date.parse(e.checkedAt)&&t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`expiresAt`],message:`Current expiry claim requires expiresAt after checkedAt`}),e.status===`expired`&&e.expiresAt!==void 0&&Date.parse(e.expiresAt)>Date.parse(e.checkedAt)&&t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`expiresAt`],message:`Expired expiry claim requires expiresAt at or before checkedAt`})),e.factKind===`quote_min_out`&&l(e.sourceEvidenceId,Zy.quote_min_out,[`evidenceClaims`,n,`sourceEvidenceId`],`evidenceClaims[${n}].quote_min_out`),e.factKind===`slippage_policy`&&(l(e.sourceEvidenceId,Zy.slippage_policy.bySource[e.policySource],[`evidenceClaims`,n,`sourceEvidenceId`],`evidenceClaims[${n}].slippage_policy`),e.policySource===`adapter_policy_from_quote_evidence`&&e.minOutRaw===void 0&&t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`minOutRaw`],message:`Adapter-derived slippage policy claim requires minOutRaw`})),e.factKind===`object_ownership`&&l(e.sourceEvidenceId,Zy.object_ownership,[`evidenceClaims`,n,`sourceEvidenceId`],`evidenceClaims[${n}].object_ownership`),e.factKind===`simulation_result`&&(l(e.sourceEvidenceId,Zy.simulation_result,[`evidenceClaims`,n,`sourceEvidenceId`],`evidenceClaims[${n}].simulation_result`),e.status===`success`&&e.missingFields.length!==0&&t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`missingFields`],message:`Successful simulation claim must not have missing required fields`}),wy.every(t=>e.requiredFields.includes(t))||t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`requiredFields`],message:`Simulation claim must include every required simulation field`}),e.status!==`success`&&e.failureReason===void 0&&t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`failureReason`],message:`Failed or unavailable simulation claim requires failureReason`}),e.status===`success`&&e.failureReason!==void 0&&t.addIssue({code:`custom`,path:[`evidenceClaims`,n,`failureReason`],message:`Successful simulation claim must not include failureReason`}))}),e.rawQuantities.forEach((e,n)=>{let r=u(e.amountClaimId,`raw_quantity_amount`,[`rawQuantities`,n,`amountClaimId`],`rawQuantities[${n}].amountClaimId`);r?.factKind===`raw_quantity_amount`&&(Y(t,e.role,r.role,[`rawQuantities`,n,`role`],`rawQuantities[${n}].role`),Y(t,e.rawAmount,r.rawAmount,[`rawQuantities`,n,`rawAmount`],`rawQuantities[${n}].rawAmount`),fb(t,e.asset,r.asset,[`rawQuantities`,n,`asset`],`rawQuantities[${n}].asset`));let i=u(e.unit.unitClaimId,`unit_metadata`,[`rawQuantities`,n,`unit`,`unitClaimId`],`rawQuantities[${n}].unit.unitClaimId`);i?.factKind===`unit_metadata`&&(Y(t,e.unit.source,i.source,[`rawQuantities`,n,`unit`,`source`],`rawQuantities[${n}].unit.source`),Y(t,e.unit.decimals,i.decimals,[`rawQuantities`,n,`unit`,`decimals`],`rawQuantities[${n}].unit.decimals`),e.asset.coinType!==void 0&&Y(t,e.asset.coinType,i.coinType,[`rawQuantities`,n,`asset`,`coinType`],`rawQuantities[${n}].asset.coinType`))}),e.gas.gasBudgetRaw!==void 0){let n=u(e.gas.gasBudgetClaimId,`raw_quantity_amount`,[`gas`,`gasBudgetClaimId`],`gas.gasBudgetClaimId`);n?.factKind===`raw_quantity_amount`&&(Y(t,n.role,Qy.gasBudgetClaimId.role,[`gas`,`gasBudgetClaimId`],`gas.gasBudgetClaimId role`),pb(t,n.asset,Qy.gasBudgetClaimId.assetCoinType,[`gas`,`gasBudgetClaimId`],`gas.gasBudgetClaimId asset`),Y(t,e.gas.gasBudgetRaw,n.rawAmount,[`gas`,`gasBudgetRaw`],`gas.gasBudgetRaw`))}if(e.gas.gasUsedRaw!==void 0){let n=u(e.gas.gasUsedClaimId,`raw_quantity_amount`,[`gas`,`gasUsedClaimId`],`gas.gasUsedClaimId`);n?.factKind===`raw_quantity_amount`&&(Y(t,n.role,Qy.gasUsedClaimId.role,[`gas`,`gasUsedClaimId`],`gas.gasUsedClaimId role`),pb(t,n.asset,Qy.gasUsedClaimId.assetCoinType,[`gas`,`gasUsedClaimId`],`gas.gasUsedClaimId asset`),Y(t,e.gas.gasUsedRaw,n.rawAmount,[`gas`,`gasUsedRaw`],`gas.gasUsedRaw`))}if(e.gas.unresolvedReason!==void 0){let n=u(e.gas.unresolvedClaimId,`gas_unresolved_status`,[`gas`,`unresolvedClaimId`],`gas.unresolvedClaimId`);n?.factKind===`gas_unresolved_status`&&(Y(t,n.status,`unresolved`,[`gas`,`unresolvedClaimId`],`gas.unresolvedClaimId status`),Y(t,e.gas.checkedAt,n.checkedAt,[`gas`,`checkedAt`],`gas.checkedAt`),Y(t,e.gas.unresolvedReason,n.reason,[`gas`,`unresolvedReason`],`gas.unresolvedReason`))}e.gas.gasObjects?.forEach((e,n)=>{let r=u(e.ownershipClaimId,`object_ownership`,[`gas`,`gasObjects`,n,`ownershipClaimId`],`gas.gasObjects[${n}].ownershipClaimId`);r?.factKind===`object_ownership`&&(Y(t,e.objectId,r.objectId,[`gas`,`gasObjects`,n,`objectId`],`gas.gasObjects[${n}].objectId`),Y(t,e.ownerAccount,r.ownerAccount,[`gas`,`gasObjects`,n,`ownerAccount`],`gas.gasObjects[${n}].ownerAccount`),Y(t,r.ownership,Qy.gasObjectOwnershipClaimId.ownership,[`gas`,`gasObjects`,n,`ownershipClaimId`],`gas.gasObjects[${n}].ownershipClaimId ownership`))});let d=u(e.expiry.evidenceClaimId,`expiry_status`,[`expiry`,`evidenceClaimId`],`expiry.evidenceClaimId`);if(d?.factKind===`expiry_status`&&(Y(t,e.expiry.status,d.status,[`expiry`,`status`],`expiry.status`),Y(t,e.expiry.checkedAt,d.checkedAt,[`expiry`,`checkedAt`],`expiry.checkedAt`),e.expiry.status===`current`||e.expiry.status===`expired`?Y(t,e.expiry.expiresAt,d.expiresAt,[`expiry`,`expiresAt`],`expiry.expiresAt`):Y(t,e.expiry.reason,d.reason,[`expiry`,`reason`],`expiry.reason`)),e.slippageOrMinOut.quoteEvidenceClaimId!==void 0){let n=u(e.slippageOrMinOut.quoteEvidenceClaimId,`quote_min_out`,[`slippageOrMinOut`,`quoteEvidenceClaimId`],`slippageOrMinOut.quoteEvidenceClaimId`);n?.factKind===`quote_min_out`&&(Y(t,e.slippageOrMinOut.quoteEvidenceId,n.quoteEvidenceId,[`slippageOrMinOut`,`quoteEvidenceId`],`slippageOrMinOut.quoteEvidenceId`),Y(t,e.slippageOrMinOut.minOutRaw,n.minOutRaw,[`slippageOrMinOut`,`minOutRaw`],`slippageOrMinOut.minOutRaw`))}if(e.slippageOrMinOut.minOutRaw!==void 0&&(e.rawQuantities.some(t=>t.role===`minimum_output`&&t.rawAmount===e.slippageOrMinOut.minOutRaw)||t.addIssue({code:`custom`,path:[`slippageOrMinOut`,`minOutRaw`],message:`slippageOrMinOut.minOutRaw must match a minimum_output rawQuantities entry`})),e.slippageOrMinOut.policyEvidenceClaimId!==void 0){let n=u(e.slippageOrMinOut.policyEvidenceClaimId,`slippage_policy`,[`slippageOrMinOut`,`policyEvidenceClaimId`],`slippageOrMinOut.policyEvidenceClaimId`);n?.factKind===`slippage_policy`&&(Y(t,e.slippageOrMinOut.policySource,n.policySource,[`slippageOrMinOut`,`policySource`],`slippageOrMinOut.policySource`),Y(t,e.slippageOrMinOut.maxSlippageBps,n.maxSlippageBps,[`slippageOrMinOut`,`maxSlippageBps`],`slippageOrMinOut.maxSlippageBps`),n.policySource===`adapter_policy_from_quote_evidence`&&Y(t,e.slippageOrMinOut.minOutRaw,n.minOutRaw,[`slippageOrMinOut`,`minOutRaw`],`slippageOrMinOut.minOutRaw`))}e.objectOwnership.objects.forEach((n,r)=>{let i=u(n.evidenceClaimId,`object_ownership`,[`objectOwnership`,`objects`,r,`evidenceClaimId`],`objectOwnership.objects[${r}].evidenceClaimId`);i?.factKind===`object_ownership`&&(Y(t,n.objectId,i.objectId,[`objectOwnership`,`objects`,r,`objectId`],`objectOwnership.objects[${r}].objectId`),Y(t,e.objectOwnership.ownerAccount,i.ownerAccount,[`objectOwnership`,`ownerAccount`],`objectOwnership.ownerAccount`),Y(t,n.ownership,i.ownership,[`objectOwnership`,`objects`,r,`ownership`],`objectOwnership.objects[${r}].ownership`))});let f=u(e.simulation.evidenceClaimId,`simulation_result`,[`simulation`,`evidenceClaimId`],`simulation.evidenceClaimId`);f?.factKind===`simulation_result`&&(Y(t,e.simulation.provider,f.provider,[`simulation`,`provider`],`simulation.provider`),Y(t,e.simulation.checksEnabled,f.checksEnabled,[`simulation`,`checksEnabled`],`simulation.checksEnabled`),Y(t,e.simulation.simulatedAt,f.simulatedAt,[`simulation`,`simulatedAt`],`simulation.simulatedAt`),Y(t,e.simulation.status,f.status,[`simulation`,`status`],`simulation.status`),db(t,e.simulation.requiredFields,f.requiredFields,[`simulation`,`requiredFields`],`simulation.requiredFields`),db(t,e.simulation.missingFields,f.missingFields,[`simulation`,`missingFields`],`simulation.missingFields`),Y(t,e.simulation.failureReason,f.failureReason,[`simulation`,`failureReason`],`simulation.failureReason`))}).superRefine((e,t)=>{let n=e.reviewedTransactionDigest;Y(t,e.humanReadableReview.transactionDigest,n,[`humanReadableReview`,`transactionDigest`],`humanReadableReview.transactionDigest`),Y(t,e.simulation.transactionDigest,n,[`simulation`,`transactionDigest`],`simulation.transactionDigest`)}),Db=B({contractVersion:G(Sy),artifactKind:G(`ptb_visualization`),generatedAt:$y,source:B({adapterId:F().min(1).max(120),planId:F().min(1).max(120).optional(),sourceKind:W([`review_time_generated_transaction_kind`,`review_time_ir`,`renderer_model`]),authority:G(`visualization_only_not_wallet_authorization`),renderer:B({name:F().min(1).max(120),packageName:F().min(1).max(120).optional(),version:F().min(1).max(80).optional()}).strict().optional()}).strict(),mermaid:B({diagramType:G(`flowchart`),text:ob(2e4,`mermaid.text`),namedText:ob(2e4,`mermaid.namedText`)}).strict(),diagnostics:z(B({severity:W([`info`,`warning`,`error`]),code:F().min(1).max(120),message:ob(512,`diagnostics.message`),source:W([`adapter`,`renderer`,`schema`,`simulation`])}).strict()).default([]),unsupportedUse:z(W(Ey)).min(1),executableMaterial:B({included:G(!1),policy:G(`mcp_and_review_ui_outputs_must_not_include_executable_transaction_material`)}).strict()}).strict().superRefine((e,t)=>{lb(t,e.unsupportedUse,Ey,[`unsupportedUse`],`unsupportedUse`)}),Ob=U(F(),R()),kb=W(_y),Ab=W(vy);W([`ready_for_wallet_review`,`refresh_required`,`blocked`]);var jb=W(yy);W([`proposed`,`awaiting_wallet`,`wallet_connected`,`ready_for_wallet_review`,`refresh_required`,`blocked`,`expired`,`awaiting_signature`,`submitting`,`awaiting_chain_result`,`stopped`,`request_failed`,`outcome_unknown`,`completed`]);var Mb=B({id:F(),label:F(),status:W([`pass`,`warning`,`fail`]),message:F(),source:W([`registry`,`quote`,`wallet`,`simulation`,`adapter`,`network`,`proposal`])}),Nb=F().min(1),Pb=`human_readable_review`,Fb=`review_time_simulation`,Ib=B({stageCatalogId:F().min(1),adapterId:F(),protocol:F(),actionKind:F(),completedStages:z(Nb),missingStages:z(Nb)}).strict().superRefine((e,t)=>{let n=Lb(e.completedStages);n&&t.addIssue({code:`custom`,path:[`completedStages`],message:`completedStages contains duplicate stage '${n}'`});let r=Lb(e.missingStages);r&&t.addIssue({code:`custom`,path:[`missingStages`],message:`missingStages contains duplicate stage '${r}'`});for(let n of e.completedStages)e.missingStages.includes(n)&&t.addIssue({code:`custom`,path:[`missingStages`],message:`stage '${n}' cannot be both completed and missing`})});function Lb(e){let t=new Set;for(let n of e){if(t.has(n))return n;t.add(n)}}var Rb=B({symbol:F(),amount:F(),coinType:F().optional(),approx:L().optional()}).strict(),zb=Rb.extend({amountKind:G(`display_intent`).default(`display_intent`)}),Bb=B({outgoing:z(zb),expectedIncoming:z(zb),minimumIncoming:z(zb).optional(),fees:z(zb).optional()}),Vb=B({outgoing:z(Rb),expectedIncoming:z(Rb),minimumIncoming:z(Rb).optional(),fees:z(Rb).optional()}),Hb=B({before:z(Rb),after:z(Rb),delta:z(Rb)}),Ub=B({computationCostRaw:k_(`computationCostRaw`),storageCostRaw:k_(`storageCostRaw`),storageRebateRaw:k_(`storageRebateRaw`),nonRefundableStorageFeeRaw:k_(`nonRefundableStorageFeeRaw`)}).strict(),Wb=B({address:d_,coinType:F().min(1).max(512).refine(e=>{try{return P_(e)===e}catch{return!1}},`Expected a normalized Sui struct tag coin type`),amount:N_(`balanceChanges[].amount`)}).strict(),Gb=B({objectId:d_,objectType:F().min(1).max(512).optional(),inputState:F().min(1).max(80),outputState:F().min(1).max(80),idOperation:F().min(1).max(80)}).strict(),Kb=B({provider:xy,checksEnabled:L(),success:L(),gasCostSummary:Ub.optional(),balanceChanges:z(Wb).optional(),objectChanges:z(Gb).optional(),error:F().optional()}),qb=Kb,Jb=Kb.extend({checksEnabled:G(!0),success:G(!0),gasCostSummary:Ub,balanceChanges:z(Wb),objectChanges:z(Gb),error:uc().optional()}).strict(),Yb=B({role:W([`input`,`expected_output`,`minimum_output`,`fee`]),symbol:F(),coinType:F().min(1).max(512).refine(e=>{try{return P_(e),!0}catch{return!1}},`Expected a Sui struct tag coin type`),decimals:I().int().min(0).max(255),rawAmount:k_(`rawAmount`),rawAmountSource:G(`quote_policy_evidence`),displayAmount:F().optional(),displayAmountSource:G(`user_display_intent_not_signing_input`).optional()}).strict().superRefine((e,t)=>{e.displayAmount!==void 0&&e.displayAmountSource===void 0&&t.addIssue({code:`custom`,path:[`displayAmountSource`],message:`displayAmountSource is required when displayAmount is present`}),e.displayAmount===void 0&&e.displayAmountSource!==void 0&&t.addIssue({code:`custom`,path:[`displayAmount`],message:`displayAmount is required when displayAmountSource is present`})}),Xb=B({role:W([`connected_account`,`output_recipient`]),address:d_}).strict(),Zb=B({kind:G(`swap_output_asset`),symbol:F(),coinType:F().min(1).max(512).refine(e=>{try{return P_(e),!0}catch{return!1}},`Expected a Sui struct tag coin type`),protocol:F(),poolKey:F(),direction:W([`base_to_quote`,`quote_to_base`])}).strict(),Qb=B({id:F(),label:F(),source:H([W([`registry`,`quote`,`wallet`,`simulation`,`adapter`,`network`,`proposal`]),W([`transaction_material`,`digest_commitment`])]),summary:F()}).strict(),$b=B({id:F(),label:F(),reason:F()}).strict(),ex=B({proposedAction:B({title:F(),summary:F(),actionKind:F(),adapterId:F(),protocol:F(),network:G(`sui:mainnet`)}).strict(),recipients:z(Xb),evidenceUsed:z(Qb),missingEvidence:z($b),requiredUserChoices:z($b),unsupportedClaims:z($b),freshness:B({status:G(`current`),evaluatedAt:F(),expiresAt:F(),reason:F()}).strict(),blockingChecks:z(Mb)}).strict(),tx=B({assetFlow:B({outgoing:z(Yb),expectedIncoming:z(Yb),minimumIncoming:z(Yb),fees:z(Yb)}).strict(),targets:z(Zb)}).strict(),nx=hc(`kind`,[ex.extend({kind:G(`swap_human_readable_review`)}).merge(tx)]),rx=B({id:F(),actionKind:F(),adapterId:F(),protocol:F(),title:F(),summary:F(),assetFlowPreview:Bb,reviewModel:gy.optional(),adapterData:Ob,createdAt:F(),expiresAt:F().optional(),registryVersion:F().optional(),preliminaryChecks:z(Mb).optional()}),ix=B({planId:F(),reviewSessionId:F(),account:d_,checks:z(Mb),assetFlowActual:Vb.optional(),beforeAfterBalance:Hb.optional(),simulation:qb.optional(),humanReadableReview:nx.optional(),transactionReviewData:Eb.optional(),ptbVisualization:Db.optional(),adapterLifecycle:Ib.optional(),updatedAt:F()}),ax=hc(`status`,[ix.extend({status:G(`ready_for_wallet_review`),evidenceValidity:uc().optional(),blockedReason:uc().optional(),refreshReason:uc().optional()}),ix.extend({status:G(`refresh_required`),evidenceValidity:G(`invalidated`).optional(),refreshReason:Ab,blockedReason:uc().optional()}),ix.extend({status:G(`blocked`),evidenceValidity:G(`invalidated`).optional(),blockedReason:kb,refreshReason:uc().optional()})]).superRefine((e,t)=>{if(e.evidenceValidity===`invalidated`)for(let n of by)e[n]!==void 0&&t.addIssue({code:`custom`,path:[n],message:`Invalidated review evidence cannot carry current material-derived facts`});let n=e.adapterLifecycle;if(n!==void 0&&ox(e,t),e.humanReadableReview!==void 0&&n===void 0&&t.addIssue({code:`custom`,path:[`humanReadableReview`],message:`humanReadableReview requires adapterLifecycle evidence stage provenance`}),e.simulation!==void 0&&n===void 0&&t.addIssue({code:`custom`,path:[`simulation`],message:`simulation requires adapterLifecycle evidence stage provenance`}),e.ptbVisualization!==void 0){let e=n?.completedStages??[];e.includes(`transaction_material_build_or_verify`)&&e.includes(`digest_commitment`)||t.addIssue({code:`custom`,path:[`ptbVisualization`],message:`ptbVisualization requires completed transaction material and digest commitment lifecycle stages`})}let r=e.status===`ready_for_wallet_review`;e.transactionReviewData!==void 0&&!r&&t.addIssue({code:`custom`,path:[`transactionReviewData`],message:`transactionReviewData is only valid on ready_for_wallet_review`}),e.status===`ready_for_wallet_review`&&n!==void 0&&(e.transactionReviewData===void 0&&t.addIssue({code:`custom`,path:[`transactionReviewData`],message:`ready_for_wallet_review requires an emitted wallet review contract`}),(n===void 0||n.missingStages.length!==0)&&t.addIssue({code:`custom`,path:[`adapterLifecycle`],message:`ready_for_wallet_review requires a completed adapterLifecycle with no missing stages`}),e.humanReadableReview===void 0&&t.addIssue({code:`custom`,path:[`humanReadableReview`],message:`ready_for_wallet_review requires humanReadableReview public evidence`}),e.simulation===void 0&&t.addIssue({code:`custom`,path:[`simulation`],message:`ready_for_wallet_review requires successful simulation public evidence`})),e.status===`blocked`&&(e.blockedReason===`producer_stage_missing`&&n===void 0&&t.addIssue({code:`custom`,path:[`adapterLifecycle`],message:`producer_stage_missing requires adapterLifecycle with at least one missing stage`}),e.blockedReason===`producer_stage_missing`&&n!==void 0&&n.missingStages.length===0&&t.addIssue({code:`custom`,path:[`blockedReason`],message:`producer_stage_missing requires at least one adapterLifecycle.missingStages entry`}),e.blockedReason===`wallet_review_contract_emit_missing`&&e.transactionReviewData!==void 0&&t.addIssue({code:`custom`,path:[`transactionReviewData`],message:`wallet_review_contract_emit_missing requires the wallet review contract to be absent`}),e.blockedReason===`wallet_review_contract_emit_missing`&&n===void 0&&t.addIssue({code:`custom`,path:[`adapterLifecycle`],message:`wallet_review_contract_emit_missing requires adapterLifecycle`}),e.blockedReason===`wallet_review_contract_emit_missing`&&n!==void 0&&n.missingStages.length!==0&&t.addIssue({code:`custom`,path:[`blockedReason`],message:`wallet_review_contract_emit_missing requires a completed adapterLifecycle with no missing stages`}),e.blockedReason===`wallet_review_contract_emit_missing`&&e.evidenceValidity!==`invalidated`&&e.humanReadableReview===void 0&&t.addIssue({code:`custom`,path:[`humanReadableReview`],message:`wallet_review_contract_emit_missing requires humanReadableReview public evidence`}),e.blockedReason===`wallet_review_contract_emit_missing`&&e.evidenceValidity!==`invalidated`&&e.simulation===void 0&&t.addIssue({code:`custom`,path:[`simulation`],message:`wallet_review_contract_emit_missing requires simulation public evidence`}))});function ox(e,t){let n=e.adapterLifecycle;n&&(e.humanReadableReview!==void 0&&sx(t,n,Pb,[`humanReadableReview`]),e.simulation!==void 0&&(sx(t,n,Fb,[`simulation`]),sx(t,n,Pb,[`simulation`]),cx(t,e.simulation,[`simulation`])),n.missingStages.includes(Fb)&&e.simulation!==void 0&&t.addIssue({code:`custom`,path:[`simulation`],message:`simulation public evidence cannot be present while review_time_simulation is missing`}),n.missingStages.includes(Pb)&&e.humanReadableReview!==void 0&&t.addIssue({code:`custom`,path:[`humanReadableReview`],message:`humanReadableReview public evidence cannot be present while human_readable_review is missing`}))}function sx(e,t,n,r){t.completedStages.includes(n)||e.addIssue({code:`custom`,path:r,message:`${r.join(`.`)} requires completed adapterLifecycle stage '${n}'`}),t.missingStages.includes(n)&&e.addIssue({code:`custom`,path:r,message:`${r.join(`.`)} cannot be present while adapterLifecycle stage '${n}' is missing`})}function cx(e,t,n){Jb.safeParse(t).success||e.addIssue({code:`custom`,path:n,message:`simulation public evidence requires a successful checks-enabled review-time simulation projection`})}var lx=B({topic:F().min(1),grants:C_,expiresAt:F().datetime(),walletName:F().optional()}).strict(),ux={topic:F().min(1),lifecycleRevision:I().int().positive(),grantRevisions:v_},dx=hc(`status`,[B({...ux,status:G(`present`),session:lx}).strict(),B({...ux,status:W([`absent`,`unusable`])}).strict()]);B({chainId:G(g_),lifecycleRevision:I().int().positive(),grantRevision:I().int().nonnegative()});var fx=B({runId:K_,sequence:I().int().positive(),observedAt:F().datetime()}).strict();fx.extend({sessions:z(dx)}).strict();var px=F().uuid(),mx={operationId:px,walletRunId:K_},hx=hc(`action`,[B({action:G(`connect`),...mx,chains:y_}).strict(),B({action:G(`disconnect`),...mx,connectionId:F().min(1),impactId:F().min(1)}).strict()]);B({}).strict();var gx=B({operationId:px,cardId:F().min(1),action:W([`connect`,`disconnect`]),status:W([`running`,`completed`,`failed`,`stopped`]),connectionId:F().min(1),createdAt:F().datetime(),updatedAt:F().datetime(),expiresAt:F().datetime(),settlementPending:L(),message:F().optional(),endReason:W([`user_stopped`,`expired`,`run_ended`]).optional()}).strict();gx.pick({operationId:!0,action:!0,status:!0,settlementPending:!0});var _x=`A wallet connection provides account context; it is not a transaction approval or proof of address ownership.`,vx=`Review evidence is not a safety guarantee. Only an explicit card action and wallet approval may authorize this exact transaction.`,yx=Q_.extend({sessionPresence:W([`present`,`absent`,`unusable`,`unconfirmed`]),chainStates:z($_).optional(),disconnectImpact:B({impactId:F(),requestCount:I().int().nonnegative(),chains:y_}).strict().optional()});W([`awaiting_approval`,`disconnect_pending`,`cleanup_pending`]);var bx=B({action:W([`prepare_review`,`request_signature`]),connectionId:F().min(1),walletRunId:K_,account:d_,reviewRevision:I().int().nonnegative()}).strict(),xx=B({action:W([`cancel`,`stop_waiting`,`read_result`])}).strict(),Sx=H([hx,B({action:G(`stop_connection`),operationId:F().uuid()}).strict(),bx,xx]),Cx=H([hx.options[0],bx.extend({action:G(`prepare_review`)})]);function wx(e,t){e.reviewTarget&&(e.review?.account&&e.review.account!==e.reviewTarget.account||e.request&&e.request.account!==e.reviewTarget.account)&&t.addIssue({code:`custom`,path:[`reviewTarget`],message:`The fixed review target must match its recorded account and request.`})}var Tx=B({kind:W(nv),message:F().optional(),reason:F().optional()}).strict(),Ex={allowedActions:z(W(tv)),actionRemainingMs:I().int().nonnegative(),nextStateReadAfterMs:I().int().nonnegative().optional(),observe:L(),walletAvailability:Y_,walletObservation:fx.optional(),progress:X_,nextStep:Tx},Dx=B({...Ex,kind:G(`connect`),mode:G(`connect`),allowedActions:z(W([`connect`,`cancel`,`stop_connection`])),boundary:G(_x),requestedChains:y_,operation:gx.optional(),automaticAction:hx.options[0].optional()}).strict(),Ox=B({...Ex,kind:G(`disconnect`),mode:G(`disconnect`),allowedActions:z(W([`disconnect`,`cancel`])),boundary:G(_x),connection:yx.optional(),operation:gx.optional()}).strict(),kx=B({reviewSessionId:F(),plan:rx,reviewRevision:I().int().nonnegative(),status:jb,account:F().optional(),preparing:L(),accountRequestPending:G(!0).optional(),error:F().optional(),state:ax.optional()}).strict(),Ax=B({connectionId:F(),account:d_}).strict(),jx=F().regex(/^-?[0-9]+$/).optional(),Mx=hc(`kind`,[Dx,Ox,B({...Ex,kind:G(`review`),mode:W([`review`,`review_manage`]),allowedActions:z(W([`prepare_review`,`request_signature`,`read_result`,`stop_waiting`,`cancel`])),boundary:G(vx),reviewTarget:Ax.optional(),review:kx,walletName:F().optional(),acceptedWalletRunId:K_.optional(),automaticAction:bx.extend({action:G(`prepare_review`)}).optional(),request:G_.optional(),receipt:R().optional(),netGasMist:jx,observationStopped:L().optional()}).strict().superRefine(wx)]),Nx=B({message:F(),recordedAt:F().datetime()}).strict(),Px={allowedActions:z(uc()),observe:G(!1),actionRemainingMs:G(0),result:Nx};B({...Px,kind:W([`connect`,`disconnect`]),result:Nx.extend({pendingWork:W([`approval_response`,`session_removal`,`session_status`]).optional()}),walletName:F().optional(),networks:z(B({chainId:__,status:W([`bound`,`not_approved`,`multiple_accounts`,`invalid_response`])}).strict())}).strict(),B({...Px,kind:G(`review`),mode:W([`review`,`review_manage`]),review:kx.optional(),reviewTarget:Ax.optional(),request:G_.optional(),receipt:R().optional(),netGasMist:jx,observationStopped:L().optional(),boundary:G(vx)}).strict().superRefine(wx);var Fx=`sui-mcp.local-data`,Ix=16777216,X=F().uuid(),Lx=I().int().nonnegative().safe(),Rx=F().regex(/^[a-f0-9]{64}$/),zx=hc(`status`,[B({status:G(`no_file`)}).strict(),B({status:G(`receiving`)}).strict(),B({status:G(`checking`)}).strict(),B({status:G(`check_required`),message:F().min(1)}).strict(),B({status:G(`can_restore`)}).strict(),B({status:G(`cannot_restore`),reason:W([`invalid_backup`,`file_unavailable`,`wallet_request_unsettled`,`operation_busy`,`input_unavailable`,`check_failed`]),message:F().min(1)}).strict()]);B({fileId:X,sha256:Rx,totalSize:Lx,dataEpoch:Lx,userDataRevision:Lx,check:zx}).strict();var Bx=hc(`kind`,[B({kind:G(`set_endpoint`),endpoint:W([`grpc`,`graphql`]),value:F().min(1)}).strict(),B({kind:G(`restore_endpoint`),endpoint:W([`grpc`,`graphql`])}).strict(),B({kind:W([`import_local_data`,`reset_local_data`,`restart_wallet_service`])}).strict()]),Vx=hc(`kind`,[B({kind:G(`clear_read_address`)}).strict(),...Bx.options,B({kind:G(`set_wallet_networks`),chains:y_}).strict(),B({kind:G(`download_backup`)}).strict()]);B({operationStatus:B({operationId:F().uuid()}).strict().optional(),backupDelivery:B({operationId:F().uuid(),fileId:F().uuid()}).strict().optional()}).strict().refine(e=>!(e.operationStatus&&e.backupDelivery),`Choose exactly one card purpose.`);var Hx=W([`acknowledged`,`not_completed`,`unconfirmed`,`unsupported`,`not_sent`]),Ux=B({method:G(`ui/download-file`),code:G(-32601)}).strict(),Wx=W([`acknowledged`,`cancelled`,`expired`,`server_restarted`,`data_replaced`,`source_unavailable`,`stored_locally`,`local_save_failed`]),Gx=B({device:F().regex(/^\d+$/),inode:F().regex(/^\d+$/)}).strict(),Kx=W([`not_published`,`target_conflict`,`source_unavailable`,`interrupted`]),qx=B({status:W([`needs_consent`,`saving`,`saved`,`failed`]),attemptId:X,fileId:X,sha256:Rx,totalSize:Lx,destination:F(),ownerId:F().min(1),currentSaveAttemptId:X.optional(),attempts:z(B({saveAttemptId:X,cardId:F().min(1),previousSaveAttemptId:X.optional(),admittedAt:F().datetime(),allowPossibleCopy:L()}).strict()),sourceIdentity:Gx.optional(),savedAt:F().datetime().optional(),failure:Kx.optional()}).strict().superRefine((e,t)=>{(e.status===`needs_consent`?e.attempts.length!==0||e.currentSaveAttemptId!==void 0:!e.currentSaveAttemptId||!e.attempts.some(t=>t.saveAttemptId===e.currentSaveAttemptId))&&t.addIssue({code:`custom`,message:`A local save must identify its admitted attempt.`}),(new Set(e.attempts.map(e=>e.saveAttemptId)).size!==e.attempts.length||e.status===`saved`!=(e.savedAt!==void 0)||e.status===`saved`&&!e.sourceIdentity||e.status===`failed`!=(e.failure!==void 0))&&t.addIssue({code:`custom`,message:`Local save evidence must match its state.`})});B({currentAttemptId:X,attempts:z(B({attemptId:X,cardId:F().min(1),admittedAt:F().datetime(),previousAttemptId:X.optional(),hostReport:Hx.optional(),failure:Ux.optional()}).strict()).min(1),readyAt:F().datetime().optional(),expiresAt:F().datetime().optional(),endReason:Wx.optional(),localSave:qx.optional()}).strict().superRefine((e,t)=>{(new Set(e.attempts.map(e=>e.attemptId)).size!==e.attempts.length||!e.attempts.some(t=>t.attemptId===e.currentAttemptId)||e.readyAt===void 0!=(e.expiresAt===void 0))&&t.addIssue({code:`custom`,message:`Download attempts and lifetime must identify one stored snapshot.`}),(e.endReason===`stored_locally`&&e.localSave?.status!==`saved`||e.endReason===`local_save_failed`&&e.localSave?.status!==`failed`||e.attempts.some(e=>e.hostReport===`unsupported`!=(e.failure!==void 0))||e.localSave&&(e.localSave.attemptId!==e.currentAttemptId||!e.attempts.some(t=>t.attemptId===e.currentAttemptId&&t.hostReport===`unsupported`)||e.localSave.status===`saving`&&e.endReason!==void 0||e.localSave.status===`saved`!=(e.endReason===`stored_locally`)))&&t.addIssue({code:`custom`,message:`Local saving requires the current download's unsupported report.`})});var Jx=W([`settings_retry_download`,`settings_report_download`,`settings_cancel_download`,`settings_store_backup`]),Yx=hc(`action`,[B({action:G(`settings_clear_read_address`),operationId:X,connectionId:F().min(1),account:F().min(1)}).strict(),B({action:G(`settings_save_wallet_networks`),operationId:X,chains:y_.transform(b_),expectedChains:y_.transform(b_)}).strict(),B({action:G(`settings_download_backup`),operationId:X,attemptId:X}).strict(),B({action:G(`settings_retry_download`),operationId:X,fileId:X,previousAttemptId:X,attemptId:X}).strict(),B({action:G(`settings_report_download`),operationId:X,fileId:X,attemptId:X,status:Hx,failure:Ux.optional()}).strict().refine(e=>e.status===`unsupported`==(e.failure!==void 0),`Only unsupported downloads require the exact method failure.`),B({action:G(`settings_store_backup`),operationId:X,fileId:X,attemptId:X,saveAttemptId:X,previousSaveAttemptId:X.optional(),allowPossibleCopy:L()}).strict(),B({action:G(`settings_cancel_download`),operationId:X,fileId:X,attemptId:X}).strict(),B({action:G(`settings_select`),draft:Bx}).strict(),B({action:G(`settings_prepare`),operationId:X}).strict(),B({action:G(`settings_begin_upload`),operationId:X,name:F().min(1),totalSize:Lx.max(Ix),sha256:Rx}).strict(),B({action:G(`settings_upload_chunk`),operationId:X,fileId:X,offset:Lx.max(Ix),chunkBase64:F()}).strict(),B({action:G(`settings_seal_upload`),operationId:X,fileId:X}).strict(),B({action:G(`settings_confirm`),operationId:X,preparationId:X}).strict(),B({action:G(`settings_back`),operationId:X}).strict(),B({action:G(`settings_cancel`)}).strict()]),Xx=B({outcome:W([`completed`,`failed`,`interrupted`,`superseded`]),recordedAt:F().datetime(),message:F().min(1),details:U(F(),R()).optional(),completionScope:G(`backup_delivery`).optional()}).strict(),Zx=B({storedValue:F(),effectiveValue:F(),source:W([`environment`,`local_db`,`builtin_default`]),pendingStoredValue:F().optional(),appliesAfter:G(`mcp_server_restart`).optional()}).strict(),Qx=B({endpoint:W([`grpc`,`graphql`]),key:W([`suiGrpcUrl`,`suiGraphqlUrl`]),value:F().min(1),status:W([`saved`,`reset`]),storedValue:F(),effectiveValue:F(),source:Zx.shape.source}).strict().refine(e=>e.key===(e.endpoint===`grpc`?`suiGrpcUrl`:`suiGraphqlUrl`),`The endpoint kind and preference key must agree.`),$x=I().int().nonnegative().safe(),eS=B({accounts:$x,reviewSessions:$x,reviewStateSnapshots:$x,reviewStatusTransitions:$x,reviewExecutions:$x,reviewRequests:$x,outcomeUnknownRequests:$x,externalActivityScans:$x,externalActivityTransactions:$x,localSettings:$x}).strict(),tS=B({status:G(`valid`),format:G(Fx),network:G(`mainnet`),exportedAt:F().datetime(),currentCounts:eS,incomingCounts:eS,willReplace:G(!0),restartRequiredAfterImport:L()}).strict(),nS=B({kind:G(`settings`),operationId:X,phase:W([`draft`,`uploading`,`sealed`,`prepared`,`executing`,`stopping`,`starting`,`terminal`]),draft:Vx.optional(),preparationId:X.optional(),preparation:U(F(),R()).optional(),file:B({fileId:X,displayName:F(),totalSize:Lx,receivedSize:Lx,sha256:Rx,sealed:L(),cleanup:W([`pending`,`complete`,`failed`])}).strict().optional(),download:B({availability:W([`preparing`,`available`,`ended`]),currentAttemptId:X,hostReport:Hx.optional(),previousUnconfirmed:L(),endReason:Wx.optional(),expiresAt:F().datetime().optional(),remainingMs:Lx.optional(),localSave:B({status:W([`needs_consent`,`saving`,`saved`,`failed`]),currentSaveAttemptId:X.optional(),failure:Kx.optional(),savedAt:F().datetime().optional()}).strict().optional(),allowedFileActions:z(Jx)}).strict().optional(),restoreCheck:zx.optional(),backupLocation:B({directory:F().min(1),filename:F().min(1)}).strict().optional(),result:Xx.optional(),temporaryFileCleanup:W([`pending`,`complete`,`failed`]).optional(),priorRunId:X.optional(),nextRunId:X.optional(),supersedesOperationId:X.optional(),supersededByOperationId:X.optional(),allowedActions:z(W(Yx.options.map(e=>e.shape.action.value))),observe:L(),facts:B({server:B({name:F(),version:F(),network:G(`mainnet`)}).strict(),localSettings:B({suiGrpcUrl:Zx,suiGraphqlUrl:Zx,walletConnectionChains:y_}).strict(),readAddress:F().optional(),readConnectionId:F().optional(),assetReadAccount:ev,walletAvailability:Y_,connectionReconciliationRequired:G(!0).optional(),observedAt:F().datetime().optional(),counts:eS}).strict().optional()}).strict().superRefine((e,t)=>{if(e.download&&(e.draft?.kind!==`download_backup`||!e.file||e.download.availability===`available`&&(!e.file.sealed||e.download.endReason||!e.download.expiresAt)||e.download.availability===`ended`&&!e.download.endReason)&&t.addIssue({code:`custom`,message:`Download delivery must describe its own snapshot and lifetime.`}),e.draft?.kind===`download_backup`&&e.preparation!==void 0&&t.addIssue({code:`custom`,message:`Private download preparation is not public preparation data.`}),e.restoreCheck&&(e.draft?.kind!==`import_local_data`||e.result)&&t.addIssue({code:`custom`,message:`Restore checks belong to an uncompleted import preparation.`}),e.restoreCheck?.status===`can_restore`&&(e.phase!==`prepared`||!e.file?.sealed||!e.allowedActions.includes(`settings_confirm`))&&t.addIssue({code:`custom`,message:`Restore availability requires a sealed file and current confirmation.`}),e.draft?.kind===`import_local_data`&&e.restoreCheck?.status!==`can_restore`&&e.allowedActions.includes(`settings_confirm`)&&t.addIssue({code:`custom`,message:`An unchecked or blocked import cannot offer confirmation.`}),e.restoreCheck?.status===`receiving`&&(!e.file||e.file.sealed||![`draft`,`uploading`].includes(e.phase))&&t.addIssue({code:`custom`,message:`Receiving requires the selected unsealed upload.`}),e.restoreCheck?.status===`check_required`&&(!e.file?.sealed||e.phase!==`sealed`)&&t.addIssue({code:`custom`,message:`A new check requires the same complete sealed upload.`}),e.restoreCheck?.status===`cannot_restore`&&e.restoreCheck.reason===`invalid_backup`&&(e.phase===`prepared`||e.allowedActions.includes(`settings_prepare`))&&t.addIssue({code:`custom`,message:`A rejected backup requires an explicit new selection.`}),e.backupLocation&&(e.result?.outcome!==`completed`||e.draft?.kind!==`download_backup`||e.download?.localSave?.status!==`saved`||e.download.endReason!==`stored_locally`)&&t.addIssue({code:`custom`,message:`A backup location requires its recorded successful export.`}),e.download?.localSave?.status===`saved`&&!e.backupLocation&&t.addIssue({code:`custom`,message:`A saved backup must identify its verified location.`}),e.temporaryFileCleanup&&!e.result&&t.addIssue({code:`custom`,message:`Cleanup of an applied or ended operation requires its recorded result.`}),(e.phase===`terminal`!=(e.result!==void 0)||e.phase===`terminal`&&(e.observe||e.allowedActions.length||e.download?.allowedFileActions.length))&&t.addIssue({code:`custom`,message:`A terminal Settings result cannot grant input or observation.`}),e.phase===`prepared`&&(!e.preparationId||!e.draft||!e.preparation)&&t.addIssue({code:`custom`,message:`Settings confirmation requires a prepared identity and facts.`}),e.phase===`prepared`&&e.draft?.kind===`import_local_data`&&!tS.safeParse(e.preparation?.preview).success&&t.addIssue({code:`custom`,path:[`preparation`,`preview`],message:`Import confirmation requires the validated current and incoming read context and record counts.`}),e.phase===`prepared`&&(e.draft?.kind===`set_endpoint`||e.draft?.kind===`restore_endpoint`)){let n=Qx.safeParse(e.preparation?.endpoint);(!n.success||n.data.endpoint!==e.draft.endpoint||n.data.status!==(e.draft.kind===`set_endpoint`?`saved`:`reset`)||e.draft.kind===`set_endpoint`&&n.data.value!==e.draft.value)&&t.addIssue({code:`custom`,path:[`preparation`,`endpoint`],message:`Endpoint confirmation must name its exact prepared target.`})}e.file&&e.file.receivedSize>e.file.totalSize&&t.addIssue({code:`custom`,message:`Received content exceeds the selected file.`})}),rS=65536;function iS(e){return new TextEncoder().encode(JSON.stringify(e)).length}function aS(e){let t=rS-iS(e);return t>0?3*Math.floor(t/4):0}function oS(e){if(!e||typeof e!=`object`)return;let t=structuredClone(e);if(t.method===`tools/call`&&t.params?.name===`ui_act_card`&&t.params.arguments?.input?.action===`settings_upload_chunk`)return t.id=2**53-1,t.params.arguments.revision=2**53-1,t.params.arguments.input.offset=Ix,t.params.arguments.input.chunkBase64=``,aS(t)}var sS={uiOpenAccount:`ui_open_account`,uiOpenReceipt:`ui_open_receipt`,uiOpenChart:`ui_open_chart`,uiReadCard:`ui_read_card`,uiSubmitCard:`ui_submit_card`,uiActCard:`ui_act_card`,uiReadSettingsFile:`ui_read_settings_file`,sessionOpenReviewManagement:`session_open_review_management`,readGetServerStatus:`read_get_server_status`,readListSupportedProtocols:`read_list_supported_protocols`,readListDeepbookPools:`read_list_deepbook_pools`,readListDeepbookTokens:`read_list_deepbook_tokens`,readInspectDeepbookOrderbook:`read_inspect_deepbook_orderbook`,readGetDeepbookMidPrice:`read_get_deepbook_mid_price`,readGetDeepbookUsdcPriceHistory:`read_get_deepbook_usdc_price_history`,readGetDeepbookUsdcPriceAtTime:`read_get_deepbook_usdc_price_at_time`,readQuoteDeepbookAction:`read_quote_deepbook_action`,readQuoteDeepbookDisplayAmount:`read_quote_deepbook_display_amount`,readSummarizeDeepbookAccountInventory:`read_summarize_deepbook_account_inventory`,readSummarizeWalletAssets:`read_summarize_wallet_assets`,readClassifyWalletAssets:`read_classify_wallet_assets`,readListSettlementAssetGroups:`read_list_settlement_asset_groups`,readSummarizeSettlementAssetGroupParity:`read_summarize_settlement_asset_group_parity`,readPreviewIntentEvidence:`read_preview_intent_evidence`,readListReviewActivity:`read_list_review_activity`,readSummarizeReviewFunnel:`read_summarize_review_funnel`,readGetReviewSessionDetail:`read_get_review_session_detail`,readInspectSuiTransaction:`read_inspect_sui_transaction`,readScanSuiAccountActivity:`read_scan_sui_account_activity`,readSummarizeSuiActivityScan:`read_summarize_sui_activity_scan`,readScanSuiFunctionActivity:`read_scan_sui_function_activity`,readSummarizeSuiFunctionActivityScan:`read_summarize_sui_function_activity_scan`,readSummarizeSuiAccountActivity:`read_summarize_sui_account_activity`,readGetAccountAssetTimeline:`read_get_account_asset_timeline`,settingsCreateLocalSettingsSession:`settings_create_local_settings_session`,settingsGetLocalSettings:`settings_get_local_settings`,actionStartReview:`action_start_review`,actionCreateProposalReview:`action_create_proposal_review`,sessionOpenWalletDisconnectionCard:`session_open_wallet_disconnection_card`,sessionOpenWalletConnectionCard:`session_open_wallet_connection_card`,sessionGetWalletConnectionCard:`session_get_wallet_connection_card`,sessionWaitWalletConnectionCard:`session_wait_wallet_connection_card`,sessionGetInteractionStatus:`session_get_interaction_status`,sessionGetReviewStatus:`session_get_review_status`,sessionGetExecutionResult:`session_get_execution_result`,sessionWaitExecutionResult:`session_wait_execution_result`,accountGetActiveAccount:`account_get_active_account`},cS=B({connectionId:F().min(1),pairingUri:F().startsWith(`wc:`),expiresAt:F().datetime()}).strict(),lS=W([`account`,`receipt`,`chart`,`connect`,`disconnect`,`review`,`settings`]),uS=B({cardId:F().min(1),kind:lS,state:W([`ready`,`running`,`closed`]),revision:I().int().nonnegative(),createdAt:F().datetime(),expiresAt:F().datetime(),input:U(F(),R()),data:R().optional(),reason:W([`completed`,`expired`,`failed`,`server_restarted`,`cancelled`]).optional(),error:F().optional()}).strict().extend({pollAfterMs:I().int().positive(),inputRemainingMs:I().int().nonnegative()}),dS=B({transactionDigest:F().min(1),pureInputs:z(B({index:I().int().nonnegative(),bytes:F().regex(/^0x(?:[0-9a-f]{2})*$/i)}).strict()).refine(e=>new Set(e.map(e=>e.index)).size===e.length,`Duplicate input index.`),ptbGraph:B({mermaid:B({text:F(),namedText:F()}).strict()}).strict().optional()}).strict(),fS=`sui-mcp/card`,pS=`sui-mcp/receipt-display`,mS=`sui-mcp/wallet-display`,hS=`sui-mcp/settings-file`,gS=`suimcp://cards/`,_S=hc(`kind`,[B({kind:G(`account`),status:G(`input_required`),field:G(`account`),message:F().min(1)}).strict(),B({kind:G(`receipt`),status:G(`input_required`),field:G(`digest`),message:F().min(1)}).strict()]),vS=B({cardId:F().min(1),permission:F().min(1)}).strict();vS.extend({revision:I().int().nonnegative(),input:U(F(),R())}).strict();var yS=dS.extend({cardId:F().min(1),revision:I().int().nonnegative(),attemptId:F().min(1).optional()}),bS=cS.extend({cardId:F().min(1),revision:I().int().nonnegative()}),xS=B({attemptId:F().uuid(),cardId:F().min(1),operationId:F().uuid(),fileId:F().uuid(),offset:I().int().nonnegative().safe(),totalSize:I().int().nonnegative().safe(),sha256:F().regex(/^[a-f0-9]{64}$/),chunkBase64:F()}).strict(),SS={account:sS.uiOpenAccount,receipt:sS.uiOpenReceipt,chart:sS.uiOpenChart,read:sS.uiReadCard,submit:sS.uiSubmitCard,act:sS.uiActCard,readSettingsFile:sS.uiReadSettingsFile};function Z(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function CS(e){return e.kind!==`import_local_data`}function wS(e,t,n){if(e.kind!==`settings`||t.kind!==`settings`||e.cardId!==t.cardId||t.state!==`ready`)return;let r=nS.safeParse(e.data),i=nS.safeParse(t.data);if(!r.success||!i.success)return;let a=r.data,o=i.data,s=o.draft;if(n.action===`settings_select`&&a.operationId===o.operationId){let r=Vx.safeParse(n.draft);if(r.success&&CS(r.data)&&(t.revision===e.revision||ES(r.data,s)))return{kind:`selection_response`,cardId:t.cardId,operationId:o.operationId,draft:r.data}}if(!s||!a.draft||a.operationId!==o.operationId||n.operationId!==o.operationId||JSON.stringify(a.draft)!==JSON.stringify(s))return;if(CS(s))return n.action===`settings_prepare`?{kind:`preparation_response`,cardId:t.cardId,operationId:o.operationId,draft:s}:void 0;let c=o.file?.fileId;if(!(!c||!a.file?.fileId||a.file.fileId!==c||n.action!==`settings_prepare`&&n.action!==`settings_seal_upload`||n.action===`settings_seal_upload`&&n.fileId!==c))return{kind:`backup_check_response`,cardId:t.cardId,operationId:o.operationId,fileId:c,action:n.action}}function TS(e){return Object.keys(e).filter(t=>e[t]!==void 0)}function ES(e,t){if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((e,n)=>ES(e,t[n]));let n=Z(e),r=Z(t);if(!n||!r)return!1;let i=TS(n);return i.length===TS(r).length&&i.every(e=>Object.hasOwn(r,e)&&ES(n[e],r[e]))}function DS(e,t=!0){let n=Z(e);if(!n)throw Error(`The app did not provide a usable card response.`);let r=()=>Error(`The app provided inconsistent card response information.`),i,a=e=>{let t=Z(e);if(!t||typeof t.ok!=`boolean`||i&&!ES(i,t))throw r();i=t};n.structuredContent!==void 0&&a(n.structuredContent);let o,s;if(Array.isArray(n.content))for(let e of n.content){let n=Z(e);if(n?.type!==`text`||typeof n.text!=`string`)continue;let i;try{i=Z(JSON.parse(n.text))}catch{continue}if(i){if(i.ok!==void 0)a(i);else if(Array.isArray(i.content)){if(!t||o)throw r();let n=Xu.safeParse(i);if(!n.success)throw r();o=DS(n.data,!1),s=e,o.structuredContent!==void 0&&a(o.structuredContent)}}}let c=Object.create(null),l=!1;for(let e of[n._meta,o?._meta]){if(e===void 0)continue;let t=Z(e);if(!t)throw r();for(let e of TS(t)){let n=t[e];if(Object.hasOwn(c,e)&&!ES(c[e],n))throw r();c[e]=n}l=!0}if(n.isError!==void 0&&typeof n.isError!=`boolean`||o?.isError!==void 0&&n.isError!==void 0&&o.isError!==n.isError||(n.isError===!0||o?.isError===!0)&&i?.ok===!0)throw r();return{...o,...n,...o?{content:[...Array.isArray(n.content)?n.content.filter(e=>e!==s):[],...Array.isArray(o.content)?o.content:[]]}:{},...i?{structuredContent:i}:{},...l?{_meta:c}:{}}}function OS(e,t){let n=Z(Z(e?.data)?.request);return!!e&&(e.kind===`receipt`||e.kind===`review`)&&t.cardId===e.cardId&&t.revision===e.revision&&t.transactionDigest===(e.kind===`receipt`?e.input.digest:n?.transactionDigest)&&(e.kind!==`review`||t.attemptId===n?.attemptId)}function kS(e){let t;for(let n of Array.isArray(e.content)?e.content:[]){let e=Z(n),r;if(e?.type===`resource_link`&&typeof e.uri==`string`&&e.uri.startsWith(`suimcp://cards/`)&&(r=e.uri),e?.type===`text`&&typeof e.text==`string`){let t=/^\[Resource link: card_([A-Za-z0-9_-]+)\] (suimcp:\/\/cards\/([A-Za-z0-9_-]+)) \(Saved data for this exact card\.\)$/.exec(e.text);if(!t&&e.text.startsWith(`[Resource link:`)&&e.text.includes(`suimcp://cards/`))throw Error(`The saved card links could not be matched to one card.`);if(t){if(t[1]!==t[3])throw Error(`The saved card links could not be matched to one card.`);r=t[2]}}if(r===void 0)continue;let i=r.slice(gS.length);if(!i||encodeURIComponent(i)!==i||t!==void 0&&i!==t||e?.type===`resource_link`&&typeof e.name==`string`&&e.name.startsWith(`card_`)&&e.name!==`card_${i}`)throw Error(`The saved card links could not be matched to one card.`);t=i}return t}function AS(e){let t=Z(e.structuredContent),n=t?.ok===!0?_S.safeParse(t.data):void 0,r=Z(Z(t?.error)?.details),i=n?.success?void 0:t?.ok===!0?Z(t.data)?.card??t.data:r?.snapshot,a=i===void 0?void 0:uS.parse(i);a?.kind===`settings`&&nS.parse(a.data);let o=Z(e._meta)?.[pS],s=o===void 0?void 0:yS.parse(o);if(s&&!OS(a,s))throw Error(`Transaction details do not match this saved result.`);let c=Z(e._meta)?.[mS],l=c===void 0?void 0:bS.parse(c);if(l&&(!a||a.kind!==`connect`||l.cardId!==a.cardId||l.revision!==a.revision||l.connectionId!==Z(Z(a.data)?.operation)?.connectionId))throw Error(`The connection QR code does not match this card.`);return{snapshot:a,display:s,wallet:l,inputRequired:n?.success?n.data:void 0,error:typeof r?.message==`string`?r.message:typeof r?.reason==`string`?r.reason:void 0}}function jS(e,t){let n=document.getElementById(`app`);if(!n)throw Error(`Card root is unavailable.`);let r=document.createElement(`h1`);r.textContent=t.title;let i=document.createElement(`p`);i.className=`ui-note`,i.setAttribute(`role`,`status`);let a=document.createElement(`p`);a.className=`ui-error`,a.setAttribute(`role`,`alert`);let o=document.createElement(`p`);o.className=`ui-note card-guidance`;let s=document.createElement(`section`),c=document.createElement(`div`);c.className=`card-actions`;let l=document.createElement(`div`);l.className=`card-progress-hint`,l.hidden=!0,n.replaceChildren(r,i,a,s,o,l,c);let u=new Zh({name:`sui-mcp-card`,version:`0.8.0`},{},{autoResize:!0,strict:!0}),d=new AbortController,f=e===`connect`||e===`disconnect`||e===`review`,p=e===`settings`,m=f||p,h=!1,g,_,v,y,b,ee,x,te=!1,ne=!1,re,ie,S={status:`unconfirmed`},ae,oe,se,C,w,T=`continue`,E,ce,le=0,ue=0,de,fe,pe,me,D,he,ge,_e,ve=!1;function ye(){if(!C||!y)return;let{input:t,basis:n}=C,r=Z(y.data),i=Z(n.data),a=Z(r?.request),o=Z(r?.review),s=Z(i?.request),c=!!a&&a.attemptId===s?.attemptId;if(!f)return y.state===`running`||y.reason===`completed`?C.delivery===`rejected`?`past`:`observed`:y.state===`closed`?`past`:`active`;if((e===`connect`||e===`disconnect`)&&typeof t.operationId==`string`){let e=Z(r?.operation)?.operationId===t.operationId?Z(r?.operation):void 0;if(t.action===`stop_connection`){if(e?.endReason===`user_stopped`)return`observed`;if(e&&e.status!==`running`)return`past`}else if(e)return`observed`}if(t.walletRunId&&t.walletRunId!==Z(r?.walletAvailability)?.walletRunId&&t.walletRunId!==r?.acceptedWalletRunId)return`past`;switch(t.action){case`connect`:break;case`prepare_review`:if(typeof o?.reviewRevision==`number`&&typeof t.reviewRevision==`number`&&o.reviewRevision>t.reviewRevision)return o.account===t.account?`observed`:`past`;break;case`request_signature`:if(a?.account===t.account&&a?.reviewRevision===t.reviewRevision)return`observed`;if(typeof o?.reviewRevision==`number`&&typeof t.reviewRevision==`number`&&o.reviewRevision>t.reviewRevision||!a&&o&&o.reviewRevision===t.reviewRevision&&o.account===t.account&&o.status===`refresh_required`&&Z(o.state)?.refreshReason===`review_evidence_stale`&&Array.isArray(r?.allowedActions)&&r.allowedActions.includes(`prepare_review`))return`past`;break;case`cancel`:if(y.reason===`cancelled`)return`observed`;break;case`disconnect`:case`stop_connection`:break;case`stop_waiting`:if(c&&(a?.requestStatus===`stopped`||r?.observationStopped===!0))return`observed`;if(c&&[`completed`,`request_failed`,`outcome_unknown`].includes(String(a?.requestStatus)))return`past`;break;case`read_result`:if(c&&(r?.observe===!0||a?.requestStatus===`completed`))return`observed`;if(c&&[`stopped`,`request_failed`].includes(String(a?.requestStatus)))return`past`}return be()||typeof r?.actionRemainingMs==`number`&&r.actionRemainingMs<=0||[`connect`,`disconnect`,`cancel`,`prepare_review`,`request_signature`].includes(String(t.action))&&(y.state!==`ready`||o?.status===`expired`)?`past`:`active`}function be(){let e=Sx.safeParse(C?.input),t=Mx.safeParse(y?.data);if(!e.success||!t.success)return!1;let n=e.data,r=t.data,i=`operationId`in n&&!!y&&y.state===`ready`&&y.input.operationId===n.operationId&&r.kind!==`review`&&!r.operation;if(n.action===`connect`)return r.kind===`connect`&&i&&JSON.stringify([...n.chains].sort())!==JSON.stringify([...r.requestedChains].sort());if(n.action===`prepare_review`||n.action===`request_signature`)return r.kind!==`review`||r.reviewTarget?.connectionId!==n.connectionId||r.reviewTarget?.account!==n.account;if(n.action!==`disconnect`||r.kind!==`disconnect`)return!1;let a=r.connection?.connectionId===n.connectionId?r.connection:void 0;return a?i&&a.disconnectImpact?.impactId!==n.impactId||r.nextStep.reason===`no_session_to_disconnect`||r.nextStep.reason===`connection_target_changed`:i}function xe(){if(!C)return;let e=ye();e&&C.disposition!==`observed`&&(e!==`active`||C.disposition===`active`)&&(C.disposition=e),C.disposition===`observed`&&(C.retryRequired=!1)}function Se(){if(y?.reason===`cancelled`)return;let e=Cx.safeParse(Z(y?.data)?.automaticAction);return C?.retryRequired&&e.success&&C.input.action===e.data.action?e.data:void 0}function Ce(e){let t={connect:`connection request`,prepare_review:`review update`,request_signature:`wallet approval request`,read_result:`transaction status check`,cancel:`cancellation request`,stop_connection:`request to stop connecting`,stop_waiting:Z(Z(e.basis.data)?.request)?.requestStatus===`awaiting_signature`?`request to stop wallet approval`:`request to stop checking the result`,disconnect:`wallet disconnect request`};return f?t[String(e.input.action)]??`request`:`data request`}function we(e){if(e!==`past`||!C)return;let t=Ce(C),n=C.input.action===`read_result`&&Z(Z(y?.data)?.request)?.requestStatus===`outcome_unknown`?` To check this transaction again, ask to open its result in chat.`:``;return`Message from an earlier ${t}: “${C.message}”${n}`}let Te,Ee;function De(){let t=Z(y?.data),n=p?Z(t?.download):void 0,r=y?.state===`closed`,i=Array.isArray(n?.allowedFileActions)?n.allowedFileActions:[],a=r?[]:[...Array.isArray(t?.allowedActions)?t.allowedActions:[],...i.filter(e=>e===`settings_report_download`||Te===void 0||Date.now()<Te)],o=e===`review`&&t?.mode===`review`&&!t.request&&!!g&&y?.state===`ready`,s=o&&de!==void 0&&Date.now()>=de,c=document.visibilityState!==`hidden`,l=d.signal.aborted||S.status===`rejected`,u=S.status===`confirmed`,v=C?.disposition,b=v===`active`,ee=C?.retryRequired===!0,x=C?.input.action===`request_signature`&&v===`active`,ne=T===`paused`,re=he?.pending?.()===!0,le=he?.displayRecovery?.(),fe=u&&!l&&!oe&&!re&&!s&&!!g,pe=fe&&!w&&!h&&(!m||!(E&&(b||ee||ne))),me=Cx.safeParse(t?.automaticAction),D=p?Z(n?.localSave):void 0,ge=!!y&&!r&&(m?t?.observe===!0||D?.status===`saving`:y.state===`running`),_e=!!_&&te&&!l&&!E&&c&&(ce===`explicit`||S.status!==`read_failed`&&(ce===`background`||S.status===`needed`&&S.automatic)),ye=c&&fe&&!ae&&!E&&!ce&&!w&&!ee&&!x&&!ne&&f&&me.success&&a.includes(me.data.action)?me.data:void 0,be=Z(t?.restoreCheck),xe=p&&fe&&y?.state===`ready`&&!y.input.backupDelivery&&!w&&!h&&!t?.result&&t?.observe!==!0&&(be?.status===`cannot_restore`&&[`operation_busy`,`wallet_request_unsettled`].includes(String(be.reason))||!a.includes(`settings_select`)||!a.includes(`settings_download_backup`)||t?.phase===`prepared`&&!a.includes(`settings_confirm`)||t?.phase===`draft`&&Z(t.draft)?.kind!==void 0&&Z(t.draft)?.kind!==`import_local_data`&&!a.includes(`settings_prepare`)),Ee;!l&&_&&(S.status===`read_failed`||ae||S.status===`unconfirmed`?Ee=`read`:S.status===`needed`?S.automatic||(Ee=`read`):oe||le||!r&&p&&[`pending`,`failed`].includes(String(t?.temporaryFileCleanup))||!r&&(D?.status===`saving`||D?.status===`needs_consent`&&!a.includes(`settings_store_backup`)||D?.status===`failed`&&D.failure===`not_published`&&!n?.endReason&&!a.includes(`settings_store_backup`))||xe?Ee=`read`:g?!r&&Z(t?.progress)?.status===`unavailable`||!r&&Z(t?.walletAvailability)?.status===`initializing`&&Z(t?.walletAvailability)?.stage===`state_sync`?Ee=`read`:!r&&!ne&&Se()?Ee=`retry`:b&&(!m&&pe&&y?.state===`ready`&&ve&&he?.selectionRecovery?Ee=`selection`:!ge&&!(ne&&a.length>0)&&!(C?.input.action===`prepare_review`&&a.includes(`prepare_review`)&&t?.automaticAction===void 0)&&f&&(Ee=`read`)):(y?.state!==`closed`||oe)&&(Ee=`read`));let De=f?t?.actionRemainingMs:y?.inputRemainingMs;Ee===`retry`&&s&&(Ee=`read`);let Oe=r?void 0:f?t?.nextStateReadAfterMs:p&&Te!==void 0?Math.max(0,Te-ue):void 0,ke=[!r&&(f?a.length>0:y?.state===`ready`)?De:void 0,Oe].filter(e=>typeof e==`number`&&Number.isFinite(e)&&e>0),Ae=!l&&!!g&&c&&!ie&&!ae&&S.status!==`read_failed`,je=Z(t?.review),Me=o&&!l&&!ae&&!oe&&!b&&!ee&&!ne&&S.status!==`read_failed`&&(re||w?.input.action===`prepare_review`||je?.preparing===!0||me.success&&me.data.action===`prepare_review`||S.status===`needed`&&je?.status===`ready_for_wallet_review`);return{current:u,inputEnabled:pe,permitted:a,disposition:v,read:_e,auto:ye,recover:Ee,paused:ne,partialDisplayFailure:le,settingsInputBlocked:xe,reviewUpdatePending:Me,reviewCommandDeliveryFailed:b&&C?.input.action===`prepare_review`,reviewHint:s?void 0:Me?re||je?.preparing||w?.input.action===`prepare_review`?`Updating review…`:`Checking status…`:o&&Z(je?.state)?.refreshReason===`review_evidence_stale`?`Review details are out of date.`:void 0,errors:[S.status===`rejected`?S.message:S.status===`read_failed`?`This card's status could not be checked. Reported message: “${S.message}”`:void 0,ae&&S.status!==`rejected`?`This card could not be opened. Reported message: “${ae}”`:void 0,b&&C?`Message for this ${Ce(C)}: “${C.message}”`:void 0,oe,le?.message],note:[se,we(v)].filter(Boolean).join(` `),expiryAt:Ae&&u&&ke.length?ue+Math.min(...ke):void 0,poll:Ae&&(ge||S.status===`needed`&&!S.automatic),lifetimeAt:!l&&c&&o?de:void 0}}function Oe(e){return e.recover===`retry`?C?.input.action===`connect`?`Retry connection`:`Retry review`:e.recover===`selection`?he?.selectionRecovery?.label:e.recover===`read`?`Check status`:void 0}function ke(e){if(d.signal.aborted)return``;let n=e.errors.some(Boolean)||e.recover!==void 0||!!y&&!g&&y.state!==`closed`||y?.state===`closed`&&y.reason!==`completed`,r=e.errors.some(Boolean)||S.status!==`confirmed`||e.recover===`retry`||e.settingsInputBlocked;if(n&&r&&S.status!==`rejected`){if(E||e.read)return`Checking status…`;let t=Oe(e);if(e.recover===`selection`&&t)return`Use ${t} to try the current selection again.`;if(t)return t===`Check status`?oe||e.partialDisplayFailure?`Use Check status to read this card and try displaying it again.`:`Use Check status to read this card again.`:t===`Retry connection`?`Use Retry connection to try connecting your wallet again.`:`Use Retry review to try again with the displayed wallet and account.`}return t.guidance?.(y,{confirmed:e.current,readOnly:!g,recoveryNeeded:n,visibleConfirmation:he?.visibleConfirmation?.(),commandPending:m&&w&&e.current&&!e.errors.some(Boolean)&&(w.phase===`confirming`||y?.state===`ready`&&!Z(y.data)?.request&&!Z(Z(y.data)?.review)?.preparing)?{phase:w.phase,action:String(w.input.action)}:void 0,approvalUnresolved:C?.input.action===`request_signature`&&e.disposition===`active`||w?.input.action===`request_signature`,automaticPaused:e.paused})??``}function Ae(e=De()){return e.inputEnabled&&y?.state===`ready`&&ve}function je(e,t=De()){return y?.state!==`closed`&&m&&t.inputEnabled&&(e?t.permitted.includes(e.action):t.permitted.length>0)}function Me(e){let t=De();return p&&h&&t.current&&!!g&&!w&&!E&&!oe&&!d.signal.aborted&&[`settings_begin_upload`,`settings_upload_chunk`,`settings_seal_upload`,`settings_retry_download`,`settings_report_download`,`settings_cancel_download`,`settings_store_backup`].includes(String(e.action))&&(t.permitted.includes(e.action)||e.action===`settings_report_download`)}function Ne(e){let u=Z(y?.data),f=s.querySelector(`.review-action-feedback`),_=s.querySelector(`.review-primary-action`);if(f){let e=s.querySelector(`.review-lifetime`);e?(e.append(l),f.prepend(a)):f.prepend(l,a),f.append(o)}else n.insertBefore(a,s),n.insertBefore(l,c),n.insertBefore(o,l);a.className=f?`ui-note`:`ui-error`,y?(r.textContent=t.titleFor?.(y)??t.title,i.textContent=S.status===`rejected`?`Card unavailable`:!e.current&&y.state===`ready`?f?``:!d.signal.aborted&&(E||e.read)?`Checking whether actions are available in this card…`:`Actions are unavailable until this card's status is checked.`:!g&&y.state!==`closed`?`View only.`:m?Z(u?.progress)?.status===`unavailable`?`Current progress is unavailable. The last recorded state is shown.`:!u?.request&&y.state===`closed`&&[`expired`,`server_restarted`,`cancelled`].includes(y.reason??``)?`This card no longer accepts actions.`:``:y.state===`running`?`Reading the requested data…`:y.reason===`completed`?``:y.error??(y.reason===`expired`?`The time to make a selection has ended.`:y.reason===`server_restarted`?`This request ended when Sui MCP restarted.`:``)):i.textContent=ie?``:S.status===`read_failed`?`Card status unavailable`:ae||S.status===`rejected`?`Card unavailable`:`Opening card…`,i.hidden=!i.textContent,a.textContent=[...new Set(e.errors.filter(Boolean))].join(` `),a.hidden=!a.textContent;let v=s.querySelector(`.review-status`);if(v){let t=!!f&&(e.reviewUpdatePending||!!a.textContent);t?v.classList.add(`review-status--reserved`):v.classList.remove(`review-status--reserved`),v.setAttribute(`aria-hidden`,String(t))}let b=s.querySelector(`.review-material-status`);if(b&&(b.textContent=b.dataset.previous===`true`||!e.current||e.reviewUpdatePending?b.dataset.previousLabel??``:b.dataset.currentLabel??``),o.textContent=[e.note,ke(e)].filter(Boolean).join(` `),o.hidden=!o.textContent,ve)for(let t of s.querySelectorAll(`input, button, select`))(!m||t.tagName!==`BUTTON`||t.dataset.cardAction!==void 0)&&(t.disabled=m?!je(void 0,e):!Ae(e));if(m)for(let t of s.querySelectorAll(`[data-card-action]`))t.disabled=!je({action:t.dataset.cardAction},e);if(p)for(let t of s.querySelectorAll(`[data-settings-file-action]`))t.disabled=t.dataset.settingsLocalBlocked===`true`||!(h?Me({action:t.dataset.cardAction}):je({action:t.dataset.cardAction},e));_&&(e.reviewUpdatePending||_.dataset.cardAction===`request_signature`&&e.reviewCommandDeliveryFailed||_.dataset.cardAction===void 0)&&(_.disabled=!0),D&&(D.disabled=!!w||!!E)}function Pe(e){try{e?.()}catch{oe=`The card display could not be closed cleanly. Its stored information is unchanged.`}}function Fe(e){if(!y||d.signal.aborted)return;if(y.state===`ready`&&S.status!==`confirmed`){if(p&&he?.update)try{he.update(y,{automaticPaused:T===`paused`,settings:qe,settingsCommandProgress:void 0,onDisplayChange:()=>k()})}catch{oe=`This card could not be displayed. Its stored information is unchanged.`}return}let n=m?{...Z(y.data),actionRemainingMs:void 0,nextStateReadAfterMs:void 0,...p&&Z(y.data)?.download?{download:{...Z(Z(y.data)?.download),remainingMs:void 0}}:{}}:void 0,r=p&&w?.phase===`sending`&&S.status===`confirmed`?wS(w.basis,y,w.input):void 0,i=`${T===`paused`}:${JSON.stringify(r)}:${y.revision}:${g!==void 0}:${b!==void 0}:${x!==void 0}:${JSON.stringify(n)}`;if(i===ge||i===_e&&!e)return;_e=i;let a=[...s.children],o=new Set([...s.querySelectorAll(`details`)].filter(e=>e.open).map(e=>e.querySelector(`summary`)?.textContent)),c,l=!1,u=!1;try{let e={automaticPaused:T===`paused`,onDisplayChange:()=>k(),wallet:x,...p?{settings:qe,settingsCommandProgress:r}:{}};if(he?.update?.(y,e)){ge=i,oe=void 0;return}if(y.state===`ready`&&g){let n=t.controls(y,e=>{Ge(e)},b,x,e);c=`node`in n?n:{node:n},l=!0}else(m||y.reason===`completed`)&&y.data!==void 0&&(c=t.result(y,b,g&&y.reason!==`cancelled`?e=>{Ge(e)}:void 0,x,e));s.replaceChildren(...c?[c.node]:[]),u=!0,c?.mount?.();for(let e of s.querySelectorAll(`details`))o.has(e.querySelector(`summary`)?.textContent)&&(e.open=!0)}catch{u&&s.replaceChildren(...a),Pe(c?.dispose),oe=`This card could not be displayed. Its stored information is unchanged.`;return}let f=he?.dispose;he=c,ve=l,ge=i,oe=void 0,Pe(f)}function Ie(t,n,r,i,a){if(d.signal.aborted||S.status===`rejected`)return!1;if(t.kind!==e||t.cardId!==_)throw S={status:`rejected`,message:`The returned information does not match this card.`},Error(`The returned information does not match this card.`);let o=Z(t.data),s=Z(o?.request),c=Z(s?.execution),l=o?.automaticAction===void 0?void 0:Cx.safeParse(o.automaticAction);if(l&&!l.success)throw Error(`This card could not start the next step.`);if(y&&t.revision<y.revision)return!1;if(y?.state===`closed`&&S.status===`confirmed`&&JSON.stringify(t)!==JSON.stringify(y))throw Error(`The completed card result cannot change.`);if(v&&[...new Set([...Object.keys(v),...Object.keys(t.input)])].some(e=>JSON.stringify(t.input[e])!==JSON.stringify(v[e])))throw S={status:`rejected`,message:`The returned information does not match this card.`},Error(`The returned information does not match this card.`);if(e===`review`&&(Z(o?.review)?.reviewSessionId!==void 0&&Z(o?.review)?.reviewSessionId!==t.input.reviewSessionId||s&&(s.reviewSessionId!==t.input.reviewSessionId||t.input.attemptId!==void 0&&s.attemptId!==t.input.attemptId)||c&&(c.reviewSessionId!==s?.reviewSessionId||c.attemptId!==s?.attemptId||c.txDigest!==s?.transactionDigest)||Z(o?.receipt)?.status===`found`&&Z(Z(o?.receipt)?.receipt)?.txDigest!==s?.transactionDigest)||e===`receipt`&&o?.status===`found`&&Z(o.receipt)?.txDigest!==t.input.digest)throw S={status:`rejected`,message:`The saved result does not match the information requested in this card.`},Error(S.message);!v&&(f||t.state!==`ready`)&&(v={...t.input});let u=r!==`preview`;if((!y||t.revision!==y.revision)&&(b=void 0,x=void 0),y=t,xe(),u){ue=Date.now();let t=p?Z(o?.download):void 0;if(t?.availability===`available`&&typeof t.remainingMs==`number`&&Number.isFinite(t.remainingMs)){let e=`${o?.operationId}:${Z(o?.file)?.fileId}:${t.expiresAt}`;Ee!==e&&(Ee=e,Te=void 0),Te=Math.min(Te??1/0,ue+Math.max(0,t.remainingMs))}else p&&t?.availability===`ended`&&(Te=void 0);g&&e===`review`&&o?.mode===`review`&&!o.request&&typeof o.actionRemainingMs==`number`&&Number.isFinite(o.actionRemainingMs)&&o.actionRemainingMs>=0&&(de=Math.min(de??1/0,ue+o.actionRemainingMs))}return r===`read`&&(S.status!==`needed`||a>S.afterRead)&&(S={status:`confirmed`},ae=void 0),n&&(b=n),x=i,!0}function Le(){fe!==void 0&&clearTimeout(fe),pe!==void 0&&clearTimeout(pe),me!==void 0&&clearTimeout(me),fe=void 0,pe=void 0,me=void 0,l.hidden=!0}function Re(e){let t=Oe(e);D?.textContent!==t&&(D?.remove(),D=void 0,t&&(D=eg(t,()=>{if(E||w||d.signal.aborted)return;let e=De();if(e.recover===`selection`&&Ae(e))he?.selectionRecovery?.retry();else if(e.recover===`retry`){let e=Se();e&&We(e)}else O()})));let n=s.querySelector(`.review-primary-action`),r=s.querySelector(`.review-primary-slot`);n&&(n.hidden=!!D&&!!r),D&&(D.disabled=!!E||!!w,r?(D.classList.add(`review-recovery-action`),r.append(D)):(D.classList.remove(`review-recovery-action`),c.append(D)))}async function O(){let e=he,t=e?.displayRecovery?.(),n=await Be(!0);n?.kind===`accepted`&&y===n.snapshot&&S.status===`confirmed`&&!d.signal.aborted&&document.visibilityState!==`hidden`&&!oe&&e===he&&t&&e?.displayRecovery?.()===t&&(t.retry(),k())}function k(e=!1){if(ie){let e=document.createElement(`p`);e.className=`ui-note`,e.textContent=ie,s.replaceChildren(e)}else Fe(e);let t=De();if(Ne(t),Le(),Re(t),d.signal.aborted||S.status===`rejected`)return;t.expiryAt!==void 0&&(pe=setTimeout(()=>{ze(),k()},Math.max(0,t.expiryAt-Date.now()))),t.reviewHint&&!a.textContent&&(l.replaceChildren(),l.textContent=t.reviewHint,l.setAttribute(`role`,`status`),l.hidden=!1);let n=s.querySelector(`.review-time-remaining`);if(n&&t.lifetimeAt!==void 0){let e=t.lifetimeAt,r=()=>{if(d.signal.aborted)return;let t=Math.max(0,e-Date.now()),i=Math.ceil(t/1e3);if(n.textContent=t>0?`Review expires in ${Math.floor(i/60)}:${String(i%60).padStart(2,`0`)}`:`Review time elapsed`,t>0)me=setTimeout(r,Math.min(1e3,t));else{let e=De();Ne(e),Re(e)}};r()}if(t.poll&&y){let e=ue+y.pollAfterMs-Date.now();fe=setTimeout(()=>{Be(!1)},e>0?e:y.pollAfterMs)}t.read?(ce=void 0,Ve()):t.auto&&(fe=setTimeout(()=>{let e=De().auto;e&&Ke(e,`automatic`)},0))}function ze(){S.status!==`rejected`&&S.status!==`read_failed`&&(S={status:`needed`,afterRead:le,automatic:!0})}function Be(e){return d.signal.aborted||S.status===`rejected`||!_||!te?Promise.resolve(void 0):E?E.promise:S.status===`read_failed`&&!e?Promise.resolve(void 0):(ce=e?`explicit`:`background`,k(),E?.promise??Promise.resolve(void 0))}function Ve(){let e=++le,t=performance.now(),n={id:e,promise:Promise.resolve().then(async()=>{try{let n,r,i;if(g){let e=AS(await He(SS.read,{...g}));if(!e.snapshot)throw Error(e.error??`Saved card data is unavailable.`);if(e.error)throw Error(e.error);n=e.snapshot,r=e.display,i=e.wallet}else{let e=`${gS}${encodeURIComponent(_)}`,t=(await u.readServerResource({uri:e},{signal:d.signal})).contents.find(t=>t.uri===e&&`text`in t);if(!t||!(`text`in t))throw Error(`Saved card data is unavailable.`);n=uS.parse(JSON.parse(t.text));let i=b??ee;r=i&&OS(n,i)?i:void 0}if(d.signal.aborted||S.status===`rejected`)return{kind:`disposed`,id:e};let a=Ie(n,r,`read`,i,e);return ee=void 0,!a&&S.status===`needed`&&e>S.afterRead&&(S={...S,automatic:!1}),k(a),a&&S.status===`confirmed`?{kind:`accepted`,snapshot:n,id:e,requestStartedAt:t}:{kind:`ignored`,id:e}}catch(t){return d.signal.aborted?{kind:`disposed`,id:e}:(S.status!==`rejected`&&(S={status:`read_failed`,message:t instanceof Error?t.message:`Saved card data could not be read. The last displayed result is unchanged.`}),{kind:`failed`,id:e})}}).finally(()=>{E===n&&(E=void 0),k()})};E=n,k()}async function He(e,t){return DS(await u.callServerTool({name:e,arguments:t},{signal:d.signal}))}function Ue(e,t,n){let r=Mx.safeParse(n.data);if(!r.success||!r.data.allowedActions.some(t=>t===e.action))return!1;let i=r.data,a=Z(t.data);return e.walletRunId&&e.walletRunId!==i.walletAvailability.walletRunId?!1:e.action===`connect`?i.kind===`connect`&&JSON.stringify(e.chains)===JSON.stringify(i.requestedChains):e.action===`prepare_review`||e.action===`request_signature`?i.kind===`review`&&i.review.reviewRevision===e.reviewRevision&&i.reviewTarget?.account===e.account&&i.reviewTarget?.connectionId===e.connectionId:e.action===`disconnect`?i.kind===`disconnect`&&i.connection?.connectionId===e.connectionId&&i.connection?.disconnectImpact?.impactId===e.impactId:e.action===`stop_connection`?i.kind===`connect`&&i.operation?.operationId===e.operationId&&i.operation?.status===`running`:JSON.stringify(t.input)===JSON.stringify(n.input)&&(i.kind!==`review`||i.request?.attemptId===Z(a?.request)?.attemptId&&i.review.reviewRevision===Z(a?.review)?.reviewRevision)}async function We(e){if(!y||E||!je(e))return;let t={input:e,basis:y,phase:`confirming`};w=t;let n=await Be(!1);w===t&&(w=void 0,n?.kind===`accepted`&&y===n.snapshot&&S.status===`confirmed`&&!d.signal.aborted&&document.visibilityState!==`hidden`&&Ue(e,t.basis,n.snapshot)&&je(e)?await Ke(e):S.status!==`read_failed`&&S.status!==`rejected`&&!d.signal.aborted&&(se=`The card state changed. Check the current selection before trying again.`),k())}async function Ge(e){f&&(C?.disposition===`active`||C?.retryRequired||T===`paused`)?await We(e):await Ke(e)}function A(e,t,n){C={input:e.input,basis:e.basis,message:t,delivery:n,disposition:`active`,retryRequired:e.input.action===`connect`||e.input.action===`prepare_review`},xe(),[`cancel`,`disconnect`,`stop_connection`,`stop_waiting`].includes(String(e.input.action))&&(T=`paused`),(m||n===`unknown`)&&ze()}async function Ke(e,t=`user`){if(!y||!g||(t===`file`?!Me(e):m?!je(e):!Ae()))return;let n={input:e,basis:y,phase:`sending`};w=n,T=`continue`,(t===`user`||C?.disposition!==`past`)&&(C=void 0),se=void 0,k();try{let t=AS(await He(m?SS.act:SS.submit,{...g,revision:n.basis.revision,input:e}));if(d.signal.aborted||S.status===`rejected`)return;if(!t.snapshot)throw Error(t.error??`The request could not be confirmed.`);t.error&&A(n,t.error,`rejected`),Ie(t.snapshot,t.display,`action`,t.wallet)}catch(e){!d.signal.aborted&&S.status!==`rejected`&&(A(n,e instanceof Error?e.message:`The request could not be confirmed.`,`unknown`),C&&(C.data=Z(e)?.data))}finally{w===n&&(w=void 0),k()}}let qe={uploadChunkLimit(e,t){return g?oS({jsonrpc:`2.0`,id:2**53-1,method:`tools/call`,params:{name:SS.act,arguments:{...g,revision:2**53-1,input:{action:`settings_upload_chunk`,operationId:e,fileId:t,offset:2**53-1,chunkBase64:``}}}})??0:0},async readCurrent(){let e=await Be(!0);if(e?.kind!==`accepted`)throw Error(`The current Settings selection could not be checked. Use Check status before continuing.`);return{snapshot:e.snapshot,requestStartedAt:e.requestStartedAt}},async act(e,t=!1){if(t?!Me(e):!je(e))throw Error(`This Settings action is unavailable until its current status has been checked.`);if(await Ke(e,t?`file`:`user`),d.signal.aborted)throw Error(`This card closed before the request finished. Reopen the same conversation to check its status.`);if(C?.input===e){let e=Error(C.message);throw e.data=C.data,e}if(!y)throw Error(`The current Settings status could not be checked.`);return y},setFileTransferActive(e){h=e,k()},async readFile(e){if(!g||!_||!De().current||d.signal.aborted)throw Error(`Backup read permission is unavailable.`);let t=await He(SS.readSettingsFile,{...g,...e}),n=xS.parse(Z(t._meta)?.[hS]);if(n.cardId!==_||n.operationId!==e.operationId||n.fileId!==e.fileId||n.offset!==e.offset||n.attemptId!==e.attemptId)throw Error(`The backup response does not match this card's selected file.`);return n},download:async(e,t,n)=>{let r=Z(Z(y?.data)?.download);if(!g||!De().current||d.signal.aborted||document.visibilityState===`hidden`||!r||r.currentAttemptId!==n||r.localSave||r.availability!==`available`||Te===void 0||Date.now()>=Te)throw Error(`This download is no longer available in this card.`);try{return{isError:(await u.downloadFile({contents:[{type:`resource`,resource:{uri:`file:///${encodeURIComponent(e)}`,mimeType:`application/json`,blob:t}}]},{signal:d.signal})).isError}}catch(e){if(e&&typeof e==`object`&&`code`in e&&e.code===-32601)return{unsupported:!0};throw e}}};async function Je(){if(te&&re!==void 0&&!ne){ne=!0;try{let t=DS(re),n=Z(t._meta);if(t._meta!==void 0&&!n)throw Error(`This card cannot accept actions with the access information provided by the app.`);let r=n?.[fS];if(r!==void 0){let e=vS.safeParse(r);if(!e.success)throw Error(`This card cannot accept actions with the access information provided by the app.`);g=e.data}let i=AS(t);if(i.inputRequired){if(i.inputRequired.kind!==e||g)throw Error(`The app provided inconsistent card input information.`);ie=i.inputRequired.message,k();return}let a=kS(t),o=[i.snapshot?.cardId,g?.cardId,a].filter(e=>e!==void 0);if(!o.length)throw Error(`Card data is unavailable.`);if(o.some(e=>e!==o[0])||i.snapshot&&i.snapshot.kind!==e)throw S={status:`rejected`,message:`The returned information does not match this card.`},Error(S.message);_=o[0];let s=i.snapshot;s&&(f||s.state!==`ready`)&&(v={...s.input}),ee=i.display,s&&g&&Ie(s,i.display,`preview`,i.wallet),ze(),k()}catch(e){if(d.signal.aborted)return;ae=e instanceof Error?e.message:`Card data could not be read.`,k()}}}u.ontoolresult=e=>{if(re===void 0)re=e,Je();else try{let t=AS(DS(re)).snapshot??y,n=AS(DS(e)).snapshot;if(t&&n&&(t.cardId!==n.cardId||t.kind!==n.kind))throw Error(`The app returned a different card.`)}catch{S={status:`rejected`,message:`The returned information does not match this card.`},k()}},u.onhostcontextchanged=e=>{e.theme&&(document.documentElement.dataset.theme=e.theme)};let Ye=()=>{document.visibilityState!==`hidden`&&g&&ne&&S.status!==`read_failed`&&y?.state!==`closed`?Be(!1):k()};document.addEventListener?.(`visibilitychange`,Ye),u.onteardown=async()=>{if(d.signal.aborted)return{};d.abort(),w=void 0,document.removeEventListener?.(`visibilitychange`,Ye);let e=he?.dispose;return he=void 0,Pe(e),k(),{}},u.connect().then(()=>{d.signal.aborted||(te=!0,document.documentElement.dataset.theme=u.getHostContext()?.theme??`light`,Je())}).catch(()=>{d.signal.aborted||(ae=`Could not connect this card to the app.`,k())})}function Q(e){var t=e.width,n=e.height;if(t<0)throw Error(`Negative width is not allowed for Size`);if(n<0)throw Error(`Negative height is not allowed for Size`);return{width:t,height:n}}function MS(e,t){return e.width===t.width&&e.height===t.height}var NS=function(){function e(e){var t=this;this._resolutionListener=function(){return t._onResolutionChanged()},this._resolutionMediaQueryList=null,this._observers=[],this._window=e,this._installResolutionListener()}return e.prototype.dispose=function(){this._uninstallResolutionListener(),this._window=null},Object.defineProperty(e.prototype,"value",{get:function(){return this._window.devicePixelRatio},enumerable:!1,configurable:!0}),e.prototype.subscribe=function(e){var t=this,n={next:e};return this._observers.push(n),{unsubscribe:function(){t._observers=t._observers.filter(function(e){return e!==n})}}},e.prototype._installResolutionListener=function(){if(this._resolutionMediaQueryList!==null)throw Error(`Resolution listener is already installed`);var e=this._window.devicePixelRatio;this._resolutionMediaQueryList=this._window.matchMedia(`all and (resolution: ${e}dppx)`),this._resolutionMediaQueryList.addListener(this._resolutionListener)},e.prototype._uninstallResolutionListener=function(){this._resolutionMediaQueryList!==null&&(this._resolutionMediaQueryList.removeListener(this._resolutionListener),this._resolutionMediaQueryList=null)},e.prototype._reinstallResolutionListener=function(){this._uninstallResolutionListener(),this._installResolutionListener()},e.prototype._onResolutionChanged=function(){var e=this;this._observers.forEach(function(t){return t.next(e._window.devicePixelRatio)}),this._reinstallResolutionListener()},e}();function PS(e){return new NS(e)}var FS=function(){function e(e,t,n){this._canvasElement=null,this._bitmapSizeChangedListeners=[],this._suggestedBitmapSize=null,this._suggestedBitmapSizeChangedListeners=[],this._devicePixelRatioObservable=null,this._canvasElementResizeObserver=null,this._canvasElement=e,this._canvasElementClientSize=Q({width:this._canvasElement.clientWidth,height:this._canvasElement.clientHeight}),this._transformBitmapSize=t??(function(e){return e}),this._allowResizeObserver=n?.allowResizeObserver??!0,this._chooseAndInitObserver()}return e.prototype.dispose=function(){var e,t;if(this._canvasElement===null)throw Error(`Object is disposed`);(e=this._canvasElementResizeObserver)==null||e.disconnect(),this._canvasElementResizeObserver=null,(t=this._devicePixelRatioObservable)==null||t.dispose(),this._devicePixelRatioObservable=null,this._suggestedBitmapSizeChangedListeners.length=0,this._bitmapSizeChangedListeners.length=0,this._canvasElement=null},Object.defineProperty(e.prototype,"canvasElement",{get:function(){if(this._canvasElement===null)throw Error(`Object is disposed`);return this._canvasElement},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canvasElementClientSize",{get:function(){return this._canvasElementClientSize},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bitmapSize",{get:function(){return Q({width:this.canvasElement.width,height:this.canvasElement.height})},enumerable:!1,configurable:!0}),e.prototype.resizeCanvasElement=function(e){this._canvasElementClientSize=Q(e),this.canvasElement.style.width=`${this._canvasElementClientSize.width}px`,this.canvasElement.style.height=`${this._canvasElementClientSize.height}px`,this._invalidateBitmapSize()},e.prototype.subscribeBitmapSizeChanged=function(e){this._bitmapSizeChangedListeners.push(e)},e.prototype.unsubscribeBitmapSizeChanged=function(e){this._bitmapSizeChangedListeners=this._bitmapSizeChangedListeners.filter(function(t){return t!==e})},Object.defineProperty(e.prototype,"suggestedBitmapSize",{get:function(){return this._suggestedBitmapSize},enumerable:!1,configurable:!0}),e.prototype.subscribeSuggestedBitmapSizeChanged=function(e){this._suggestedBitmapSizeChangedListeners.push(e)},e.prototype.unsubscribeSuggestedBitmapSizeChanged=function(e){this._suggestedBitmapSizeChangedListeners=this._suggestedBitmapSizeChangedListeners.filter(function(t){return t!==e})},e.prototype.applySuggestedBitmapSize=function(){if(this._suggestedBitmapSize!==null){var e=this._suggestedBitmapSize;this._suggestedBitmapSize=null,this._resizeBitmap(e),this._emitSuggestedBitmapSizeChanged(e,this._suggestedBitmapSize)}},e.prototype._resizeBitmap=function(e){var t=this.bitmapSize;MS(t,e)||(this.canvasElement.width=e.width,this.canvasElement.height=e.height,this._emitBitmapSizeChanged(t,e))},e.prototype._emitBitmapSizeChanged=function(e,t){var n=this;this._bitmapSizeChangedListeners.forEach(function(r){return r.call(n,e,t)})},e.prototype._suggestNewBitmapSize=function(e){var t=this._suggestedBitmapSize,n=Q(this._transformBitmapSize(e,this._canvasElementClientSize)),r=MS(this.bitmapSize,n)?null:n;(t!==null||r!==null)&&(t!==null&&r!==null&&MS(t,r)||(this._suggestedBitmapSize=r,this._emitSuggestedBitmapSizeChanged(t,r)))},e.prototype._emitSuggestedBitmapSizeChanged=function(e,t){var n=this;this._suggestedBitmapSizeChangedListeners.forEach(function(r){return r.call(n,e,t)})},e.prototype._chooseAndInitObserver=function(){var e=this;this._allowResizeObserver?RS().then(function(t){return t?e._initResizeObserver():e._initDevicePixelRatioObservable()}):this._initDevicePixelRatioObservable()},e.prototype._initDevicePixelRatioObservable=function(){var e=this;if(this._canvasElement!==null){var t=LS(this._canvasElement);if(t===null)throw Error(`No window is associated with the canvas`);this._devicePixelRatioObservable=PS(t),this._devicePixelRatioObservable.subscribe(function(){return e._invalidateBitmapSize()}),this._invalidateBitmapSize()}},e.prototype._invalidateBitmapSize=function(){if(this._canvasElement!==null){var e=LS(this._canvasElement);if(e!==null){var t=this._devicePixelRatioObservable?.value??e.devicePixelRatio,n=this._canvasElement.getClientRects(),r=n[0]===void 0?Q({width:this._canvasElementClientSize.width*t,height:this._canvasElementClientSize.height*t}):zS(n[0],t);this._suggestNewBitmapSize(r)}}},e.prototype._initResizeObserver=function(){var e=this;this._canvasElement!==null&&(this._canvasElementResizeObserver=new ResizeObserver(function(t){var n=t.find(function(t){return t.target===e._canvasElement});if(n&&n.devicePixelContentBoxSize&&n.devicePixelContentBoxSize[0]){var r=n.devicePixelContentBoxSize[0],i=Q({width:r.inlineSize,height:r.blockSize});e._suggestNewBitmapSize(i)}}),this._canvasElementResizeObserver.observe(this._canvasElement,{box:`device-pixel-content-box`}))},e}();function IS(e,t){if(t.type===`device-pixel-content-box`)return new FS(e,t.transform,t.options);throw Error(`Unsupported binding target`)}function LS(e){return e.ownerDocument.defaultView}function RS(){return new Promise(function(e){var t=new ResizeObserver(function(n){e(n.every(function(e){return`devicePixelContentBoxSize`in e})),t.disconnect()});t.observe(document.body,{box:`device-pixel-content-box`})}).catch(function(){return!1})}function zS(e,t){return Q({width:Math.round(e.left*t+e.width*t)-Math.round(e.left*t),height:Math.round(e.top*t+e.height*t)-Math.round(e.top*t)})}var BS=function(){function e(e,t,n){if(t.width===0||t.height===0)throw TypeError(`Rendering target could only be created on a media with positive width and height`);if(this._mediaSize=t,n.width===0||n.height===0)throw TypeError(`Rendering target could only be created using a bitmap with positive integer width and height`);this._bitmapSize=n,this._context=e}return e.prototype.useMediaCoordinateSpace=function(e){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),this._context.scale(this._horizontalPixelRatio,this._verticalPixelRatio),e({context:this._context,mediaSize:this._mediaSize})}finally{this._context.restore()}},e.prototype.useBitmapCoordinateSpace=function(e){try{return this._context.save(),this._context.setTransform(1,0,0,1,0,0),e({context:this._context,mediaSize:this._mediaSize,bitmapSize:this._bitmapSize,horizontalPixelRatio:this._horizontalPixelRatio,verticalPixelRatio:this._verticalPixelRatio})}finally{this._context.restore()}},Object.defineProperty(e.prototype,"_horizontalPixelRatio",{get:function(){return this._bitmapSize.width/this._mediaSize.width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_verticalPixelRatio",{get:function(){return this._bitmapSize.height/this._mediaSize.height},enumerable:!1,configurable:!0}),e}();function VS(e,t){var n=e.canvasElementClientSize;if(n.width===0||n.height===0)return null;var r=e.bitmapSize;if(r.width===0||r.height===0)return null;var i=e.canvasElement.getContext(`2d`,t);return i===null?null:new BS(i,n,r)}var HS={title:``,visible:!0,hitTestTolerance:3,lastValueVisible:!0,priceLineVisible:!0,priceLineSource:0,priceLineWidth:1,priceLineColor:``,priceLineStyle:2,baseLineVisible:!0,baseLineWidth:1,baseLineColor:`#B2B5BE`,baseLineStyle:0,priceFormat:{type:`price`,precision:2,minMove:.01}},US,WS;function GS(e,t){let n=function(e,t){switch(e){case 0:default:return[];case 1:return[t,t];case 2:return[2*t,2*t];case 3:return[6*t,6*t];case 4:return[t,4*t]}}(t,e.lineWidth);return e.setLineDash(n),n}function KS(e,t,n,r){e.beginPath();let i=e.lineWidth%2?.5:0;e.moveTo(n,t+i),e.lineTo(r,t+i),e.stroke()}function qS(e,t){if(!e)throw Error(`Assertion failed`+(t?`: `+t:``))}function JS(e){if(e===void 0)throw Error(`Value is undefined`);return e}function $(e){if(e===null)throw Error(`Value is null`);return e}function YS(e){return $(JS(e))}(function(e){e[e.Simple=0]=`Simple`,e[e.WithSteps=1]=`WithSteps`,e[e.Curved=2]=`Curved`})(US||={}),function(e){e[e.Solid=0]=`Solid`,e[e.Dotted=1]=`Dotted`,e[e.Dashed=2]=`Dashed`,e[e.LargeDashed=3]=`LargeDashed`,e[e.SparseDotted=4]=`SparseDotted`}(WS||={});var XS=class{constructor(){this.t=[]}i(e,t,n){let r={h:e,l:t,o:!0===n};this.t.push(r)}_(e){let t=this.t.findIndex((t=>e===t.h));t>-1&&this.t.splice(t,1)}u(e){this.t=this.t.filter((t=>t.l!==e))}p(e,t,n){let r=[...this.t];this.t=this.t.filter((e=>!e.o)),r.forEach((r=>r.h(e,t,n)))}v(){return this.t.length>0}m(){this.t=[]}};function ZS(e,...t){for(let n of t)for(let t in n)n[t]!==void 0&&Object.prototype.hasOwnProperty.call(n,t)&&![`__proto__`,`constructor`,`prototype`].includes(t)&&(typeof n[t]!=`object`||e[t]===void 0||Array.isArray(n[t])?e[t]=n[t]:ZS(e[t],n[t]));return e}function QS(e){return typeof e==`number`&&isFinite(e)}function $S(e){return typeof e==`number`&&e%1==0}function eC(e){return typeof e==`string`}function tC(e){return typeof e==`boolean`}function nC(e){let t=e;if(!t||typeof t!=`object`)return t;let n,r,i;for(r in n=Array.isArray(t)?[]:{},t)t.hasOwnProperty(r)&&(i=t[r],n[r]=i&&typeof i==`object`?nC(i):i);return n}function rC(e){return e!==null}function iC(e){return e===null?void 0:e}var aC=`-apple-system, BlinkMacSystemFont, 'Trebuchet MS', Roboto, Ubuntu, sans-serif`;function oC(e,t,n){return t===void 0&&(t=aC),`${n=n===void 0?``:`${n} `}${e}px ${t}`}var sC=class{constructor(e){this.M={S:1,C:5,P:NaN,k:``,T:``,R:``,D:``,I:0,V:0,B:0,A:0,L:0},this.O=e}N(){let e=this.M,t=this.F(),n=this.W();return e.P===t&&e.T===n||(e.P=t,e.T=n,e.k=oC(t,n),e.A=2.5/12*t,e.I=e.A,e.V=t/12*e.C,e.B=t/12*e.C,e.L=0),e.R=this.H(),e.D=this.U(),this.M}H(){return this.O.N().layout.textColor}U(){return this.O.$()}F(){return this.O.N().layout.fontSize}W(){return this.O.N().layout.fontFamily}};function cC(e){return e<0?0:e>255?255:Math.round(e)||0}function lC(e){return .199*e[0]+.687*e[1]+.114*e[2]}var uC=class{constructor(e,t){this.j=new Map,this.q=e,t&&(this.j=t)}Y(e,t){if(e===`transparent`)return e;let n=this.K(e),r=n[3];return`rgba(${n[0]}, ${n[1]}, ${n[2]}, ${t*r})`}G(e){let t=this.K(e);return{Z:`rgb(${t[0]}, ${t[1]}, ${t[2]})`,X:lC(t)>160?`black`:`white`}}J(e){return lC(this.K(e))}tt(e,t,n){let[r,i,a,o]=this.K(e),[s,c,l,u]=this.K(t),d=[cC(r+n*(s-r)),cC(i+n*(c-i)),cC(a+n*(l-a)),(f=o+n*(u-o),f<=0||f>1?Math.min(Math.max(f,0),1):Math.round(1e4*f)/1e4)];var f;return`rgba(${d[0]}, ${d[1]}, ${d[2]}, ${d[3]})`}K(e){let t=this.j.get(e);if(t)return t;let n=function(e){let t=document.createElement(`div`);t.style.display=`none`,document.body.appendChild(t),t.style.color=e;let n=window.getComputedStyle(t).color;return document.body.removeChild(t),n}(e).match(/^rgba?\s*\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d+))?\)$/);if(!n){if(this.q.length)for(let t of this.q){let n=t(e);if(n)return this.j.set(e,n),n}throw Error(`Failed to parse color: ${e}`)}let r=[parseInt(n[1],10),parseInt(n[2],10),parseInt(n[3],10),n[4]?parseFloat(n[4]):1];return this.j.set(e,r),r}},dC=class{constructor(){this.it=[]}nt(e){this.it=e}st(e,t,n){this.it.forEach((r=>{r.st(e,t,n)}))}},fC=class{st(e,t,n){e.useBitmapCoordinateSpace((e=>this.et(e,t,n)))}},pC=class extends fC{constructor(){super(...arguments),this.rt=null}ht(e){this.rt=e}et({context:e,horizontalPixelRatio:t,verticalPixelRatio:n}){if(this.rt===null||this.rt.lt===null)return;let r=this.rt.lt,i=this.rt,a=Math.max(1,Math.floor(t))%2/2,o=o=>{e.beginPath();for(let s=r.to-1;s>=r.from;--s){let r=i.ot[s],c=Math.round(r._t*t)+a,l=r.ut*n,u=o*n+a;e.moveTo(c,l),e.arc(c,l,u,0,2*Math.PI)}e.fill()};i.ct>0&&(e.fillStyle=i.dt,o(i.ft+i.ct)),e.fillStyle=i.vt,o(i.ft)}};function mC(){return{ot:[{_t:0,ut:0,wt:0,Mt:0}],vt:``,dt:``,ft:0,ct:0,lt:null}}var hC={from:0,to:1},gC=class{constructor(e,t,n){this.gt=new dC,this.bt=[],this.St=[],this.xt=!0,this.O=e,this.Ct=t,this.yt=n,this.gt.nt(this.bt)}Pt(e){this.kt(),this.xt=!0}Tt(){return this.xt&&=(this.Rt(),!1),this.gt}kt(){let e=this.yt.Dt();e.length!==this.bt.length&&(this.St=e.map(mC),this.bt=this.St.map((e=>{let t=new pC;return t.ht(e),t})),this.gt.nt(this.bt))}Rt(){let e=this.Ct.N().mode===2||!this.Ct.It(),t=this.yt.Vt(),n=this.Ct.Bt(),r=this.O.Et();this.kt(),t.forEach(((t,i)=>{let a=this.St[i],o=t.At(n),s=t.Lt();!e&&o!==null&&t.It()&&s!==null?(a.vt=o.zt,a.ft=o.ft,a.ct=o.Ot,a.ot[0].Mt=o.Mt,a.ot[0].ut=t.Ft().Nt(o.Mt,s.Wt),a.dt=o.Ht??this.O.Ut(a.ot[0].ut/t.Ft().$t()),a.ot[0].wt=n,a.ot[0]._t=r.jt(n),a.lt=hC):a.lt=null}))}},_C=class extends fC{constructor(e){super(),this.qt=e}et({context:e,bitmapSize:t,horizontalPixelRatio:n,verticalPixelRatio:r}){if(this.qt===null)return;let i=this.qt.Yt.It,a=this.qt.Kt.It;if(!i&&!a)return;let o=Math.round(this.qt._t*n),s=Math.round(this.qt.ut*r);e.lineCap=`butt`,i&&o>=0&&(e.lineWidth=Math.floor(this.qt.Yt.ct*n),e.strokeStyle=this.qt.Yt.R,e.fillStyle=this.qt.Yt.R,GS(e,this.qt.Yt.Gt),function(e,t,n,r){e.beginPath();let i=e.lineWidth%2?.5:0;e.moveTo(t+i,n),e.lineTo(t+i,r),e.stroke()}(e,o,0,t.height)),a&&s>=0&&(e.lineWidth=Math.floor(this.qt.Kt.ct*r),e.strokeStyle=this.qt.Kt.R,e.fillStyle=this.qt.Kt.R,GS(e,this.qt.Kt.Gt),KS(e,s,0,t.width))}},vC=class{constructor(e,t){this.xt=!0,this.Zt={Yt:{ct:1,Gt:0,R:``,It:!1},Kt:{ct:1,Gt:0,R:``,It:!1},_t:0,ut:0},this.Xt=new _C(this.Zt),this.Jt=e,this.yt=t}Pt(){this.xt=!0}Tt(e){return this.xt&&=(this.Rt(),!1),this.Xt}Rt(){let e=this.Jt.It(),t=this.yt.Qt().N().crosshair,n=this.Zt;if(t.mode===2)return n.Kt.It=!1,void(n.Yt.It=!1);n.Kt.It=e&&this.Jt.ti(this.yt),n.Yt.It=e&&this.Jt.ii(),n.Kt.ct=t.horzLine.width,n.Kt.Gt=t.horzLine.style,n.Kt.R=t.horzLine.color,n.Yt.ct=t.vertLine.width,n.Yt.Gt=t.vertLine.style,n.Yt.R=t.vertLine.color,n._t=this.Jt.ni(),n.ut=this.Jt.si()}};function yC(e,t,n,r,i,a){e.fillRect(t+a,n,r-2*a,a),e.fillRect(t+a,n+i-a,r-2*a,a),e.fillRect(t,n,a,i),e.fillRect(t+r-a,n,a,i)}function bC(e,t,n,r,i,a){e.save(),e.globalCompositeOperation=`copy`,e.fillStyle=a,e.fillRect(t,n,r,i),e.restore()}function xC(e,t,n,r,i,a){e.beginPath(),e.roundRect?e.roundRect(t,n,r,i,a):(e.lineTo(t+r-a[1],n),a[1]!==0&&e.arcTo(t+r,n,t+r,n+a[1],a[1]),e.lineTo(t+r,n+i-a[2]),a[2]!==0&&e.arcTo(t+r,n+i,t+r-a[2],n+i,a[2]),e.lineTo(t+a[3],n+i),a[3]!==0&&e.arcTo(t,n+i,t,n+i-a[3],a[3]),e.lineTo(t,n+a[0]),a[0]!==0&&e.arcTo(t,n,t+a[0],n,a[0]))}function SC(e,t,n,r,i,a,o=0,s=[0,0,0,0],c=``){if(e.save(),!o||!c||c===a)return xC(e,t,n,r,i,s),e.fillStyle=a,e.fill(),void e.restore();let l=o/2;var u;xC(e,t+l,n+l,r-o,i-o,(u=-l,s.map((e=>e===0?e:e+u)))),a!==`transparent`&&(e.fillStyle=a,e.fill()),c!==`transparent`&&(e.lineWidth=o,e.strokeStyle=c,e.closePath(),e.stroke()),e.restore()}function CC(e,t,n,r,i,a,o){e.save(),e.globalCompositeOperation=`copy`;let s=e.createLinearGradient(0,0,0,i);s.addColorStop(0,a),s.addColorStop(1,o),e.fillStyle=s,e.fillRect(t,n,r,i),e.restore()}var wC=class{constructor(e,t){this.ht(e,t)}ht(e,t){this.qt=e,this.ei=t}$t(e,t){return this.qt.It?e.P+e.A+e.I:0}st(e,t,n,r){if(!this.qt.It||this.qt.ri.length===0)return;let i=this.qt.R,a=this.ei.Z,o=e.useBitmapCoordinateSpace((e=>{let o=e.context;o.font=t.k;let s=this.hi(e,t,n,r),c=s.ai;return s.li?SC(o,c.oi,c._i,c.ui,c.ci,a,c.di,[c.ft,0,0,c.ft],a):SC(o,c.fi,c._i,c.ui,c.ci,a,c.di,[0,c.ft,c.ft,0],a),this.qt.pi&&(o.fillStyle=i,o.fillRect(c.fi,c.mi,c.wi-c.fi,c.Mi)),this.qt.gi&&(o.fillStyle=t.D,o.fillRect(s.li?c.bi-c.di:0,c._i,c.di,c.Si-c._i)),s}));e.useMediaCoordinateSpace((({context:e})=>{let n=o.xi;e.font=t.k,e.textAlign=o.li?`right`:`left`,e.textBaseline=`middle`,e.fillStyle=i,e.fillText(this.qt.ri,n.Ci,(n._i+n.Si)/2+n.yi)}))}hi(e,t,n,r){let{context:i,bitmapSize:a,mediaSize:o,horizontalPixelRatio:s,verticalPixelRatio:c}=e,l=this.qt.pi||!this.qt.Pi?t.C:0,u=this.qt.ki?t.S:0,d=t.A+this.ei.Ti,f=t.I+this.ei.Ri,p=t.V,m=t.B,h=this.qt.ri,g=t.P,_=n.Di(i,h),v=Math.ceil(n.Ii(i,h)),y=g+d+f,b=t.S+p+m+v+l,ee=Math.max(1,Math.floor(c)),x=Math.round(y*c);x%2!=ee%2&&(x+=1);let te=u>0?Math.max(1,Math.floor(u*s)):0,ne=Math.round(b*s),re=Math.round(l*s),ie=this.ei.Vi??this.ei.Bi??this.ei.Ei,S=Math.round(ie*c)-Math.floor(.5*c),ae=Math.floor(S+ee/2-x/2),oe=ae+x,se=r===`right`,C=se?o.width-u:u,w=se?a.width-te:te,T,E,ce;return se?(T=w-ne,E=w-re,ce=C-l-p-u):(T=w+ne,E=w+re,ce=C+l+p),{li:se,ai:{_i:ae,mi:S,Si:oe,ui:ne,ci:x,ft:2*s,di:te,oi:T,fi:w,wi:E,Mi:ee,bi:a.width},xi:{_i:ae/c,Si:oe/c,Ci:ce,yi:_}}}},TC=class{constructor(e){this.Ai={Ei:0,Z:`#000`,Ri:0,Ti:0},this.Li={ri:``,It:!1,pi:!0,Pi:!1,Ht:``,R:`#FFF`,gi:!1,ki:!1},this.zi={ri:``,It:!1,pi:!1,Pi:!0,Ht:``,R:`#FFF`,gi:!0,ki:!0},this.xt=!0,this.Oi=new(e||wC)(this.Li,this.Ai),this.Ni=new(e||wC)(this.zi,this.Ai)}ri(){return this.Fi(),this.Li.ri}Ei(){return this.Fi(),this.Ai.Ei}Pt(){this.xt=!0}$t(e,t=!1){return Math.max(this.Oi.$t(e,t),this.Ni.$t(e,t))}Wi(){return this.Ai.Vi??null}Hi(){return this.Ai.Vi??this.Ai.Bi??this.Ei()}Ui(e){this.Ai.Bi=e??void 0}$i(){return this.Fi(),this.Li.It||this.zi.It}ji(){return this.Fi(),this.Li.It}Tt(e){return this.Fi(),this.Li.pi=this.Li.pi&&e.N().ticksVisible,this.zi.pi=this.zi.pi&&e.N().ticksVisible,this.Oi.ht(this.Li,this.Ai),this.Ni.ht(this.zi,this.Ai),this.Oi}qi(){return this.Fi(),this.Oi.ht(this.Li,this.Ai),this.Ni.ht(this.zi,this.Ai),this.Ni}Fi(){this.xt&&(this.Li.pi=!0,this.zi.pi=!1,this.Yi(this.Li,this.zi,this.Ai))}},EC=class extends TC{constructor(e,t,n){super(),this.Jt=e,this.Ki=t,this.Gi=n}Yi(e,t,n){if(e.It=!1,this.Jt.N().mode===2)return;let r=this.Jt.N().horzLine;if(!r.labelVisible)return;let i=this.Ki.Lt();if(!this.Jt.It()||this.Ki.Zi()||i===null)return;let a=this.Ki.Xi().G(r.labelBackgroundColor);n.Z=a.Z,e.R=a.X;let o=2/12*this.Ki.P();n.Ti=o,n.Ri=o;let s=this.Gi(this.Ki);n.Ei=s.Ei,e.ri=this.Ki.Ji(s.Mt,i),e.It=!0}},DC=/[1-9]/g,OC=class{constructor(){this.qt=null}ht(e){this.qt=e}st(e,t){if(this.qt===null||!1===this.qt.It||this.qt.ri.length===0)return;let n=e.useMediaCoordinateSpace((({context:e})=>(e.font=t.k,Math.round(t.Qi.Ii(e,$(this.qt).ri,DC)))));if(n<=0)return;let r=t.tn,i=n+2*r,a=i/2,o=this.qt.nn,s=this.qt.Ei,c=Math.floor(s-a)+.5;c<0?(s+=Math.abs(0-c),c=Math.floor(s-a)+.5):c+i>o&&(s-=Math.abs(o-(c+i)),c=Math.floor(s-a)+.5);let l=c+i,u=Math.ceil(0+t.S+t.C+t.A+t.P+t.I);e.useBitmapCoordinateSpace((({context:e,horizontalPixelRatio:n,verticalPixelRatio:r})=>{let i=$(this.qt);e.fillStyle=i.Z;let a=Math.round(c*n),o=Math.round(0*r),s=Math.round(l*n),d=Math.round(u*r),f=Math.round(2*n);if(e.beginPath(),e.moveTo(a,o),e.lineTo(a,d-f),e.arcTo(a,d,a+f,d,f),e.lineTo(s-f,d),e.arcTo(s,d,s,d-f,f),e.lineTo(s,o),e.fill(),i.pi){let a=Math.round(i.Ei*n),s=o,c=Math.round((s+t.C)*r);e.fillStyle=i.R;let l=Math.max(1,Math.floor(n)),u=Math.floor(.5*n);e.fillRect(a-u,s,l,c-s)}})),e.useMediaCoordinateSpace((({context:e})=>{let n=$(this.qt),i=0+t.S+t.C+t.A+t.P/2;e.font=t.k,e.textAlign=`left`,e.textBaseline=`middle`,e.fillStyle=n.R;let a=t.Qi.Di(e,`Apr0`);e.translate(c+r,i+a),e.fillText(n.ri,0,0)}))}},kC=class{constructor(e,t,n){this.xt=!0,this.Xt=new OC,this.Zt={It:!1,Z:`#4c525e`,R:`white`,ri:``,nn:0,Ei:NaN,pi:!0},this.Ct=e,this.sn=t,this.Gi=n}Pt(){this.xt=!0}Tt(){return this.xt&&=(this.Rt(),!1),this.Xt.ht(this.Zt),this.Xt}Rt(){let e=this.Zt;if(e.It=!1,this.Ct.N().mode===2)return;let t=this.Ct.N().vertLine;if(!t.labelVisible)return;let n=this.sn.Et();if(n.Zi())return;e.nn=n.nn();let r=this.Gi();if(r===null)return;e.Ei=r.Ei;let i=n.en(this.Ct.Bt());e.ri=n.rn($(i)),e.It=!0;let a=this.sn.Xi().G(t.labelBackgroundColor);e.Z=a.Z,e.R=a.X,e.pi=n.N().ticksVisible}},AC=class{constructor(){this.hn=null,this.an=0}ln(){return this.an}_n(e){this.an=e}Ft(){return this.hn}un(e){this.hn=e}cn(e){return[]}dn(){return[]}It(){return!0}},jC;(function(e){e[e.Normal=0]=`Normal`,e[e.Magnet=1]=`Magnet`,e[e.Hidden=2]=`Hidden`,e[e.MagnetOHLC=3]=`MagnetOHLC`})(jC||={});var MC=class extends AC{constructor(e,t){super(),this.yt=null,this.fn=NaN,this.pn=0,this.vn=!1,this.mn=new Map,this.wn=!1,this.Mn=new WeakMap,this.gn=new WeakMap,this.bn=NaN,this.Sn=NaN,this.xn=NaN,this.Cn=NaN,this.sn=e,this.yn=t,this.Pn=((e,t)=>n=>{let r=t(),i=e();if(n===$(this.yt).kn())return{Mt:i,Ei:r};{let e=$(n.Lt());return{Mt:n.Tn(r,e),Ei:r}}})((()=>this.fn),(()=>this.Sn));let n=((e,t)=>()=>{let n=this.sn.Et().Rn(e()),r=t();return n&&Number.isFinite(r)?{wt:n,Ei:r}:null})((()=>this.pn),(()=>this.ni()));this.Dn=new kC(this,e,n)}N(){return this.yn}In(e,t){this.xn=e,this.Cn=t}Vn(){this.xn=NaN,this.Cn=NaN}Bn(){return this.xn}En(){return this.Cn}An(e,t,n){this.wn||=!0,this.vn=!0,this.Ln(e,t,n)}Bt(){return this.pn}ni(){return this.bn}si(){return this.Sn}It(){return this.vn}zn(){this.vn=!1,this.On(),this.fn=NaN,this.bn=NaN,this.Sn=NaN,this.yt=null,this.Vn(),this.Nn()}Fn(e){if(!this.yn.doNotSnapToHiddenSeriesIndices)return e;let t=this.sn,n=t.Et(),r=null,i=null;for(let n of t.Wn()){let t=n.Un().Hn(e,-1);if(t){if(t.$n===e)return e;(r===null||t.$n>r)&&(r=t.$n)}let a=n.Un().Hn(e,1);if(a){if(a.$n===e)return e;(i===null||a.$n<i)&&(i=a.$n)}}let a=[r,i].filter(rC);if(a.length===0)return e;let o=n.jt(e),s=a.map((e=>Math.abs(o-n.jt(e))));return a[s.indexOf(Math.min(...s))]}jn(e){let t=this.Mn.get(e);t||(t=new vC(this,e),this.Mn.set(e,t));let n=this.gn.get(e);return n||(n=new gC(this.sn,this,e),this.gn.set(e,n)),[t,n]}ti(e){return e===this.yt&&this.yn.horzLine.visible}ii(){return this.yn.vertLine.visible}qn(e,t){this.vn&&this.yt===e||this.mn.clear();let n=[];return this.yt===e&&n.push(this.Yn(this.mn,t,this.Pn)),n}dn(){return this.vn?[this.Dn]:[]}Kn(){return this.yt}Nn(){this.sn.Gn().forEach((e=>{this.Mn.get(e)?.Pt(),this.gn.get(e)?.Pt()})),this.mn.forEach((e=>e.Pt())),this.Dn.Pt()}Zn(e){return e&&!e.kn().Zi()?e.kn():null}Ln(e,t,n){this.Xn(e,t,n)&&this.Nn()}Xn(e,t,n){let r=this.bn,i=this.Sn,a=this.fn,o=this.pn,s=this.yt,c=this.Zn(n);this.pn=e,this.bn=isNaN(e)?NaN:this.sn.Et().jt(e),this.yt=n;let l=c===null?null:c.Lt();return c!==null&&l!==null?(this.fn=t,this.Sn=c.Nt(t,l)):(this.fn=NaN,this.Sn=NaN),r!==this.bn||i!==this.Sn||o!==this.pn||a!==this.fn||s!==this.yt}On(){let e=this.sn.Jn().map((e=>e.Un().Qn())).filter(rC),t=e.length===0?null:Math.max(...e);this.pn=t===null?NaN:t}Yn(e,t,n){let r=e.get(t);return r===void 0&&(r=new EC(this,t,n),e.set(t,r)),r}};function NC(e){return e===`left`||e===`right`}var PC=class e{constructor(e){this.ts=new Map,this.ns=[],this.ss=e}es(e,t){let n=function(e,t){return e===void 0?t:{rs:Math.max(e.rs,t.rs),hs:e.hs||t.hs}}(this.ts.get(e),t);this.ts.set(e,n)}ls(){return this.ss}_s(e){let t=this.ts.get(e);return t===void 0?{rs:this.ss}:{rs:Math.max(this.ss,t.rs),hs:t.hs}}us(){this.cs(),this.ns=[{ds:0}]}fs(e){this.cs(),this.ns=[{ds:1,Wt:e}]}ps(e){this.vs(),this.ns.push({ds:5,Wt:e})}cs(){this.vs(),this.ns.push({ds:6})}ws(){this.cs(),this.ns=[{ds:4}]}Ms(e){this.cs(),this.ns.push({ds:2,Wt:e})}gs(e){this.cs(),this.ns.push({ds:3,Wt:e})}bs(){return this.ns}Ss(e){for(let t of e.ns)this.xs(t);this.ss=Math.max(this.ss,e.ss),e.ts.forEach(((e,t)=>{this.es(t,e)}))}static Cs(){return new e(2)}static ys(){return new e(3)}xs(e){switch(e.ds){case 0:this.us();break;case 1:this.fs(e.Wt);break;case 2:this.Ms(e.Wt);break;case 3:this.gs(e.Wt);break;case 4:this.ws();break;case 5:this.ps(e.Wt);break;case 6:this.vs()}}vs(){let e=this.ns.findIndex((e=>e.ds===5));e!==-1&&this.ns.splice(e,1)}},FC=class{formatTickmarks(e){return e.map((e=>this.format(e)))}},IC=`.`;function LC(e,t){if(!QS(e))return`n/a`;if(!$S(t)||t<0||t>16)throw TypeError(`invalid length`);return t===0?e.toString():(`0000000000000000`+e.toString()).slice(-t)}var RC=class extends FC{constructor(e,t){if(super(),t||=1,QS(e)&&$S(e)||(e=100),e<0)throw TypeError(`invalid base`);this.Ki=e,this.Ps=t,this.ks()}format(e){let t=e<0?`−`:``;return e=Math.abs(e),t+this.Ts(e)}ks(){if(this.Rs=0,this.Ki>0&&this.Ps>0){let e=this.Ki;for(;e>1;)e/=10,this.Rs++}}Ts(e){let t=this.Ki/this.Ps,n=Math.floor(e),r=``,i=this.Rs===void 0?NaN:this.Rs;if(t>1){let a=+(Math.round(e*t)-n*t).toFixed(this.Rs);a>=t&&(a-=t,n+=1),r=IC+LC(+a.toFixed(this.Rs)*this.Ps,i)}else n=Math.round(n*t)/t,i>0&&(r=IC+LC(0,i));return n.toFixed(0)+r}},zC=class extends RC{constructor(e=100){super(e)}format(e){return`${super.format(e)}%`}},BC=class extends FC{constructor(e){super(),this.Ds=e}format(e){let t=``;return e<0&&(t=`-`,e=-e),e<995?t+this.Is(e):e<999995?t+this.Is(e/1e3)+`K`:e<999999995?(e=1e3*Math.round(e/1e3),t+this.Is(e/1e6)+`M`):(e=1e6*Math.round(e/1e6),t+this.Is(e/1e9)+`B`)}Is(e){let t,n=10**this.Ds;return t=(e=Math.round(e*n)/n)>=1e-15&&e<1?e.toFixed(this.Ds).replace(/\.?0+$/,``):String(e),t.replace(/(\.[1-9]*)0+$/,((e,t)=>t))}},VC=/[2-9]/g,HC=class{constructor(e=50){this.Vs=0,this.Bs=1,this.Es=1,this.As={},this.Ls=new Map,this.zs=e}Os(){this.Vs=0,this.Ls.clear(),this.Bs=1,this.Es=1,this.As={}}Ii(e,t,n){return this.Ns(e,t,n).width}Di(e,t,n){let r=this.Ns(e,t,n);return((r.actualBoundingBoxAscent||0)-(r.actualBoundingBoxDescent||0))/2}Ns(e,t,n){let r=n||VC,i=String(t).replace(r,`0`);if(this.Ls.has(i))return JS(this.Ls.get(i)).Fs;if(this.Vs===this.zs){let e=this.As[this.Es];delete this.As[this.Es],this.Ls.delete(e),this.Es++,this.Vs--}e.save(),e.textBaseline=`middle`;let a=e.measureText(i);return e.restore(),a.width===0&&t.length||(this.Ls.set(i,{Fs:a,Ws:this.Bs}),this.As[this.Bs]=i,this.Vs++,this.Bs++),a}},UC=class{constructor(e){this.Hs=null,this.M=null,this.Us=`right`,this.$s=e}js(e,t,n){this.Hs=e,this.M=t,this.Us=n}st(e){this.M!==null&&this.Hs!==null&&this.Hs.st(e,this.M,this.$s,this.Us)}},WC=class{constructor(e,t,n){this.qs=e,this.$s=new HC(50),this.Ys=t,this.O=n,this.F=-1,this.Xt=new UC(this.$s)}Tt(){let e=this.O.Ks(this.Ys);if(e===null)return null;let t=e.Gs(this.Ys)?e.Zs():this.Ys.Ft();if(t===null)return null;let n=e.Xs(t);if(n===`overlay`)return null;let r=this.O.Js();return r.P!==this.F&&(this.F=r.P,this.$s.Os()),this.Xt.js(this.qs.qi(),r,n),this.Xt}},GC=class extends fC{constructor(){super(...arguments),this.qt=null}ht(e){this.qt=e}Qs(e,t){if(!this.qt?.It)return null;let{ut:n,ct:r,te:i}=this.qt;return t>=n-r-7&&t<=n+r+7?{ie:this.qt,ne:Math.abs(t-n),se:2,ee:`price-line`,te:i}:null}et({context:e,bitmapSize:t,horizontalPixelRatio:n,verticalPixelRatio:r}){if(this.qt===null||!1===this.qt.It)return;let i=Math.round(this.qt.ut*r);i<0||i>t.height||(e.lineCap=`butt`,e.strokeStyle=this.qt.R,e.lineWidth=Math.floor(this.qt.ct*n),GS(e,this.qt.Gt),KS(e,i,0,t.width))}},KC=class{constructor(e){this.re={ut:0,R:`rgba(0, 0, 0, 0)`,ct:1,Gt:0,It:!1},this.he=new GC,this.xt=!0,this.ae=e,this.le=e.Qt(),this.he.ht(this.re)}Pt(){this.xt=!0}Tt(){return this.ae.It()?(this.xt&&=(this.oe(),!1),this.he):null}},qC=class extends KC{constructor(e){super(e)}oe(){this.re.It=!1;let e=this.ae.Ft(),t=e._e()._e;if(t!==2&&t!==3)return;let n=this.ae.N();if(!n.baseLineVisible||!this.ae.It())return;let r=this.ae.Lt();r!==null&&(this.re.It=!0,this.re.ut=e.Nt(r.Wt,r.Wt),this.re.R=n.baseLineColor,this.re.ct=n.baseLineWidth,this.re.Gt=n.baseLineStyle)}},JC=class extends fC{constructor(){super(...arguments),this.qt=null}ht(e){this.qt=e}ue(){return this.qt}et({context:e,horizontalPixelRatio:t,verticalPixelRatio:n}){let r=this.qt;if(r===null)return;let i=Math.max(1,Math.floor(t)),a=i%2/2,o=Math.round(r.ce.x*t)+a,s=r.ce.y*n;e.fillStyle=r.de,e.beginPath();let c=Math.max(2,1.5*r.fe)*t;e.arc(o,s,c,0,2*Math.PI,!1),e.fill(),e.fillStyle=r.pe,e.beginPath(),e.arc(o,s,r.ft*t,0,2*Math.PI,!1),e.fill(),e.lineWidth=i,e.strokeStyle=r.ve,e.beginPath(),e.arc(o,s,r.ft*t+i/2,0,2*Math.PI,!1),e.stroke()}},YC=[{me:0,we:.25,Me:4,ge:10,be:.25,Se:0,xe:.4,Ce:.8},{me:.25,we:.525,Me:10,ge:14,be:0,Se:0,xe:.8,Ce:0},{me:.525,we:1,Me:14,ge:14,be:0,Se:0,xe:0,Ce:0}],XC=class{constructor(e){this.Xt=new JC,this.xt=!0,this.ye=!0,this.Pe=performance.now(),this.ke=this.Pe-1,this.Te=e}Re(){this.ke=this.Pe-1,this.Pt()}De(){if(this.Pt(),this.Te.N().lastPriceAnimation===2){let e=performance.now(),t=this.ke-e;if(t>0)return void(t<650&&(this.ke+=2600));this.Pe=e,this.ke=e+2600}}Pt(){this.xt=!0}Ie(){this.ye=!0}It(){return this.Te.N().lastPriceAnimation!==0}Ve(){switch(this.Te.N().lastPriceAnimation){case 0:return!1;case 1:return!0;case 2:return performance.now()<=this.ke}}Tt(){return this.xt?(this.Rt(),this.xt=!1,this.ye=!1):this.ye&&=(this.Be(),!1),this.Xt}Rt(){this.Xt.ht(null);let e=this.Te.Qt().Et(),t=e.Ee(),n=this.Te.Lt();if(t===null||n===null)return;let r=this.Te.Ae(!0);if(r.Le||!t.ze(r.$n))return;let i={x:e.jt(r.$n),y:this.Te.Ft().Nt(r.Mt,n.Wt)},a=r.R,o=this.Te.N().lineWidth,s=this.Oe(this.Ne(),a);this.Xt.ht({de:a,fe:o,pe:s.pe,ve:s.ve,ft:s.ft,ce:i})}Be(){let e=this.Xt.ue();if(e!==null){let t=this.Oe(this.Ne(),e.de);e.pe=t.pe,e.ve=t.ve,e.ft=t.ft}}Ne(){return this.Ve()?performance.now()-this.Pe:2599}Fe(e,t,n,r){let i=n+(r-n)*t;return this.Te.Qt().Xi().Y(e,i)}Oe(e,t){let n=e%2600/2600,r;for(let e of YC)if(n>=e.me&&n<=e.we){r=e;break}qS(r!==void 0,`Last price animation internal logic error`);let i=(n-r.me)/(r.we-r.me);return{pe:this.Fe(t,i,r.be,r.Se),ve:this.Fe(t,i,r.xe,r.Ce),ft:(a=i,o=r.Me,s=r.ge,o+(s-o)*a)};var a,o,s}},ZC=class extends KC{constructor(e){super(e)}oe(){let e=this.re;e.It=!1;let t=this.ae.N();if(!t.priceLineVisible||!this.ae.It())return;let n=this.ae.Ae(t.priceLineSource===0);n.Le||(e.It=!0,e.ut=n.Ei,e.R=this.ae.We(n.R),e.ct=t.priceLineWidth,e.Gt=t.priceLineStyle)}},QC=class extends TC{constructor(e){super(),this.Jt=e}Yi(e,t,n){e.It=!1,t.It=!1;let r=this.Jt;if(!r.It())return;let i=r.N(),a=i.lastValueVisible,o=r.He()!==``,s=i.seriesLastValueMode===0,c=r.Ae(!1);if(c.Le)return;a&&(e.ri=this.Ue(c,a,s),e.It=e.ri.length!==0),(o||s)&&(t.ri=this.$e(c,a,o,s),t.It=t.ri.length>0);let l=r.We(c.R),u=this.Jt.Qt().Xi().G(l);n.Z=u.Z,n.Ei=c.Ei,t.Ht=r.Qt().Ut(c.Ei/r.Ft().$t()),e.Ht=l,e.R=u.X,t.R=u.X}$e(e,t,n,r){let i=``,a=this.Jt.He();return n&&a.length!==0&&(i+=`${a} `),t&&r&&(i+=this.Jt.Ft().je()?e.qe:e.Ye),i.trim()}Ue(e,t,n){return t?n?this.Jt.Ft().je()?e.Ye:e.qe:e.ri:``}};function $C(e,t,n,r){let i=Number.isFinite(t),a=Number.isFinite(n);return i&&a?e(t,n):i||a?i?t:n:r}var ew=class e{constructor(e,t){this.Ke=e,this.Ge=t}Ze(e){return e!==null&&this.Ke===e.Ke&&this.Ge===e.Ge}Xe(){return new e(this.Ke,this.Ge)}Je(){return this.Ke}Qe(){return this.Ge}tr(){return this.Ge-this.Ke}Zi(){return this.Ge===this.Ke||Number.isNaN(this.Ge)||Number.isNaN(this.Ke)}Ss(t){return t===null?this:new e($C(Math.min,this.Je(),t.Je(),-1/0),$C(Math.max,this.Qe(),t.Qe(),1/0))}ir(e){if(!QS(e)||this.Ge-this.Ke===0)return;let t=.5*(this.Ge+this.Ke),n=this.Ge-t,r=this.Ke-t;n*=e,r*=e,this.Ge=t+n,this.Ke=t+r}nr(e){QS(e)&&(this.Ge+=e,this.Ke+=e)}sr(){return{minValue:this.Ke,maxValue:this.Ge}}static er(t){return t===null?null:new e(t.minValue,t.maxValue)}},tw=class e{constructor(e,t){this.rr=e,this.hr=t||null}ar(){return this.rr}lr(){return this.hr}sr(){return{priceRange:this.rr===null?null:this.rr.sr(),margins:this.hr||void 0}}static er(t){return t===null?null:new e(ew.er(t.priceRange),t.margins)}},nw=[2,4,8,16,32,64,128,256,512],rw=`Custom series with conflation reducer must have a priceValueBuilder method`,iw=class extends KC{constructor(e,t){super(e),this._r=t}oe(){let e=this.re;e.It=!1;let t=this._r.N();if(!this.ae.It()||!t.lineVisible)return;let n=this._r.ur();n!==null&&(e.It=!0,e.ut=n,e.R=t.color,e.ct=t.lineWidth,e.Gt=t.lineStyle,e.te=this._r.N().id)}},aw=class extends TC{constructor(e,t){super(),this.Te=e,this._r=t}Yi(e,t,n){e.It=!1,t.It=!1;let r=this._r.N(),i=r.axisLabelVisible,a=r.title!==``,o=this.Te;if(!i||!o.It())return;let s=this._r.ur();if(s===null)return;a&&(t.ri=r.title,t.It=!0),t.Ht=o.Qt().Ut(s/o.Ft().$t()),e.ri=this.cr(r.price),e.It=!0;let c=this.Te.Qt().Xi().G(r.axisLabelColor||r.color);n.Z=c.Z;let l=r.axisLabelTextColor||c.X;e.R=l,t.R=l,n.Ei=s}cr(e){let t=this.Te.Lt();return t===null?``:this.Te.Ft().Ji(e,t.Wt)}},ow=class{constructor(e,t){this.Te=e,this.yn=t,this.dr=new iw(e,this),this.qs=new aw(e,this),this.pr=new WC(this.qs,e,e.Qt())}vr(e){ZS(this.yn,e),this.Pt(),this.Te.Qt().mr()}N(){return this.yn}wr(){return this.dr}Mr(){return this.pr}gr(){return this.qs}Pt(){this.dr.Pt(),this.qs.Pt()}ur(){let e=this.Te,t=e.Ft();if(e.Qt().Et().Zi()||t.Zi())return null;let n=e.Lt();return n===null?null:t.Nt(this.yn.price,n.Wt)}},sw=class{constructor(){this.br=new WeakMap}Sr(e,t,n){let r=1/t*n;if(e>=r)return 1;let i=r/e;return Math.min(2**Math.floor(Math.log2(i)),512)}Cr(e,t,n,r=!1,i){if(e.length===0||t<=1)return e;let a=this.yr(t);if(a<=1)return e;let o=this.Pr(e),s=o.kr.get(a);return s!==void 0||(s=this.Tr(e,a,n,r,i,o.kr),o.kr.set(a,s)),s}Rr(e,t,n,r,i=!1,a){if(n<1||e.length===0)return e;let o=this.Pr(e),s=o.kr.get(n);if(!s)return this.Cr(e,n,r,i,a);let c=this.Dr(e,t,n,s,i,r,a);return o.kr.set(n,c),c}yr(e){if(e<=2)return 2;for(let t of nw)if(e<=t)return t;return 512}Ir(e){if(e.length===0)return 0;let t=e[0],n=e[e.length-1];return 31*e.length+17*t.$n+13*n.$n}Tr(e,t,n,r=!1,i,a=new Map){if(t===2)return this.Vr(e,2,n,r,i);let o=t/2,s=a.get(o);return s||(s=this.Tr(e,o,n,r,i,a),a.set(o,s)),this.Br(s,n,r,i)}Vr(e,t,n,r=!1,i){let a=this.Er(e,t,n,r,i);return this.Ar(a,r)}Br(e,t,n=!1,r){let i=this.Er(e,2,t,n,r);return this.Ar(i,n)}Er(e,t,n,r=!1,i){let a=[];for(let o=0;o<e.length;o+=t)if(e.length-o>=t){let t=this.Lr(e[o],e[o+1],n,r,i);t.zr=!1,a.push(t)}else if(a.length===0)a.push(this.Or(e[o],!0));else{let t=a[a.length-1];a[a.length-1]=this.Nr(t,e[o],n,r,i)}return a}Fr(e,t){return(e??1)+(t??1)}Lr(e,t,n,r=!1,i){if(!r||!n||!i){let n=e.Wt[1]>t.Wt[1]?e.Wt[1]:t.Wt[1],r=e.Wt[2]<t.Wt[2]?e.Wt[2]:t.Wt[2];return{Wr:e.$n,Hr:t.$n,Ur:e.wt,$r:t.wt,jr:e.Wt[0],qr:n,Yr:r,Kr:t.Wt[3],Gr:this.Fr(e.Gr,t.Gr),Zr:void 0,zr:!1}}let a=n(this.Xr(e,i),this.Xr(t,i)),o=i(a),s=o.length?o[o.length-1]:0;return{Wr:e.$n,Hr:t.$n,Ur:e.wt,$r:t.wt,jr:e.Wt[0],qr:Math.max(e.Wt[1],s),Yr:Math.min(e.Wt[2],s),Kr:s,Gr:this.Fr(e.Gr,t.Gr),Zr:a,zr:!1}}Nr(e,t,n,r=!1,i){if(!r||!n||!i)return{Wr:e.Wr,Hr:t.$n,Ur:e.Ur,$r:t.wt,jr:e.jr,qr:e.qr>t.Wt[1]?e.qr:t.Wt[1],Yr:e.Yr<t.Wt[2]?e.Yr:t.Wt[2],Kr:t.Wt[3],Gr:e.Gr+(t.Gr??1),Zr:e.Zr,zr:!1};let a=e.Zr,o=this.Xr(t,i),s=a?{data:a,index:e.Wr,originalTime:e.Ur,time:e.Ur,priceValues:i(a)}:null,c=s?n(s,o):o.data,l=s?i(c):o.priceValues,u=l.length?l[l.length-1]:0;return{Wr:e.Wr,Hr:t.$n,Ur:e.Ur,$r:t.wt,jr:e.jr,qr:Math.max(e.qr,u),Yr:Math.min(e.Yr,u),Kr:u,Gr:e.Gr+(t.Gr??1),Zr:c,zr:!1}}Jr(e,t,n,r,i,a,o=!1,s){let c=t===r?i:e[t];if(n-t==1)return this.Or(c,!0);let l=t+1===r?i:e[t+1],u=this.Lr(c,l,a,o,s);for(let c=t+2;c<n;c++){let t=c===r?i:e[c];u=this.Nr(u,t,a,o,s)}return u}Xr(e,t){let n=e.ue??{};return{data:e.ue,index:e.$n,originalTime:e.Qr,time:e.wt,priceValues:t(n)}}th(e,t=!1){let n=!0===t,r=!!e.Zr;return{$n:e.Wr,wt:e.Ur,Qr:e.Ur,Wt:[n?e.Kr:e.jr,e.qr,e.Yr,e.Kr],Gr:e.Gr,ue:n?r?e.Zr:{wt:e.Ur}:void 0}}Ar(e,t=!1){return e.map((e=>this.th(e,t)))}Dr(e,t,n,r,i=!1,a,o){if(r.length===0)return r;let s=e.length-1,c=Math.floor(s/n)*n;if(Math.min(c+n,e.length)-c<n&&e.length>n){let r=e.slice();return r[r.length-1]=t,this.Cr(r,n,a,i,o)}if(Math.floor((s-1)/n)===Math.floor(s/n)||r.length===1){let l=Math.min(c+n,e.length),u=l-c;if(u<=0)return r;let d=u===1?this.Or(c===s?t:e[c],!0):this.Jr(e,c,l,s,t,a,i,o);return r[r.length-1]=this.th(d,i),r}{let r=e.slice();return r[r.length-1]=t,this.Cr(r,n,a,i,o)}}Or(e,t=!1){return{Wr:e.$n,Hr:e.$n,Ur:e.wt,$r:e.wt,jr:e.Wt[0],qr:e.Wt[1],Yr:e.Wt[2],Kr:e.Wt[3],Gr:e.Gr??1,Zr:e.ue,zr:t}}Pr(e){let t=this.ih(e),n=this.Ir(e);return t.nh!==n&&(t.kr.clear(),t.nh=n),t}ih(e){let t=this.br.get(e);return t===void 0&&(t={nh:this.Ir(e),kr:new Map},this.br.set(e,t)),t}},cw=class extends AC{constructor(e){super(),this.sn=e}Qt(){return this.sn}},lw={Bar:(e,t,n,r)=>{let i=t.upColor,a=t.downColor,o=$(e(n,r)),s=YS(o.Wt[0])<=YS(o.Wt[3]);return{sh:o.R??(s?i:a)}},Candlestick:(e,t,n,r)=>{let i=t.upColor,a=t.downColor,o=t.borderUpColor,s=t.borderDownColor,c=t.wickUpColor,l=t.wickDownColor,u=$(e(n,r)),d=YS(u.Wt[0])<=YS(u.Wt[3]);return{sh:u.R??(d?i:a),eh:u.Ht??(d?o:s),rh:u.hh??(d?c:l)}},Custom:(e,t,n,r)=>({sh:$(e(n,r)).R??t.color}),Area:(e,t,n,r)=>{let i=$(e(n,r));return{sh:i.vt??t.lineColor,vt:i.vt??t.lineColor,ah:i.ah??t.topColor,oh:i.oh??t.bottomColor}},Baseline:(e,t,n,r)=>{let i=$(e(n,r));return{sh:i.Wt[3]>=t.baseValue.price?t.topLineColor:t.bottomLineColor,_h:i._h??t.topLineColor,uh:i.uh??t.bottomLineColor,dh:i.dh??t.topFillColor1,fh:i.fh??t.topFillColor2,ph:i.ph??t.bottomFillColor1,mh:i.mh??t.bottomFillColor2}},Line:(e,t,n,r)=>{let i=$(e(n,r));return{sh:i.R??t.color,vt:i.R??t.color}},Histogram:(e,t,n,r)=>({sh:$(e(n,r)).R??t.color})},uw=class{constructor(e){this.wh=(e,t)=>t===void 0?this.Te.Un().Mh(e):t.Wt,this.Te=e,this.gh=lw[e.bh()]}Sh(e,t){return this.gh(this.wh,this.Te.N(),e,t)}};function dw(e,t,n,r,i=0,a=t.length){let o=a-i;for(;0<o;){let a=o>>1,s=i+a;r(t[s],n)===e?(i=s+1,o-=a+1):o=a}return i}var fw=dw.bind(null,!0),pw=dw.bind(null,!1),mw;(function(e){e[e.NearestLeft=-1]=`NearestLeft`,e[e.None=0]=`None`,e[e.NearestRight=1]=`NearestRight`})(mw||={});var hw=30,gw=class{constructor(){this.xh=[],this.Ch=new Map,this.yh=new Map,this.Ph=[]}kh(){return this.Th()>0?this.xh[this.xh.length-1]:null}Rh(){return this.Th()>0?this.Dh(0):null}Qn(){return this.Th()>0?this.Dh(this.xh.length-1):null}Th(){return this.xh.length}Zi(){return this.Th()===0}ze(e){return this.Ih(e,0)!==null}Mh(e){return this.Hn(e)}Hn(e,t=0){let n=this.Ih(e,t);return n===null?null:{...this.Vh(n),$n:this.Dh(n)}}Bh(){return this.xh}Eh(e,t,n){if(this.Zi())return null;let r=null;for(let i of n)r=_w(r,this.Ah(e,t,i));return r}ht(e){this.yh.clear(),this.Ch.clear(),this.xh=e,this.Ph=e.map((e=>e.$n))}Lh(){return this.Ph}Dh(e){return this.xh[e].$n}Vh(e){return this.xh[e]}Ih(e,t){let n=this.zh(e);if(n===null&&t!==0)switch(t){case-1:return this.Oh(e);case 1:return this.Nh(e);default:throw TypeError(`Unknown search mode`)}return n}Oh(e){let t=this.Fh(e);return t>0&&--t,t!==this.xh.length&&this.Dh(t)<e?t:null}Nh(e){let t=this.Wh(e);return t!==this.xh.length&&e<this.Dh(t)?t:null}zh(e){let t=this.Fh(e);return t===this.xh.length||e<this.xh[t].$n?null:t}Fh(e){return fw(this.xh,e,((e,t)=>e.$n<t))}Wh(e){return pw(this.xh,e,((e,t)=>e.$n>t))}Hh(e,t,n){let r=null;for(let i=e;i<t;i++){let e=this.xh[i].Wt[n];Number.isNaN(e)||(r===null?r={Uh:e,$h:e}:(e<r.Uh&&(r.Uh=e),e>r.$h&&(r.$h=e)))}return r}Ah(e,t,n){if(this.Zi())return null;let r=null,i=$(this.Rh()),a=$(this.Qn()),o=Math.max(e,i),s=Math.min(t,a),c=Math.ceil(o/hw)*hw,l=Math.max(c,Math.floor(s/hw)*hw);{let e=this.Fh(o),i=this.Wh(Math.min(s,c,t));r=_w(r,this.Hh(e,i,n))}let u=this.Ch.get(n);u===void 0&&(u=new Map,this.Ch.set(n,u));for(let e=Math.max(c+1,o);e<l;e+=hw){let t=Math.floor(e/hw),i=u.get(t);if(i===void 0){let e=this.Fh(t*hw),r=this.Wh((t+1)*hw-1);i=this.Hh(e,r,n),u.set(t,i)}r=_w(r,i)}{let e=this.Fh(l),t=this.Wh(s);r=_w(r,this.Hh(e,t,n))}return r}};function _w(e,t){return e===null?t:t===null?e:{Uh:Math.min(e.Uh,t.Uh),$h:Math.max(e.$h,t.$h)}}function vw(){return new gw}var yw={setLineStyle:GS},bw=class{constructor(e){this.jh=e}st(e,t,n){this.jh.draw(e,yw)}qh(e,t,n){this.jh.drawBackground?.(e,yw)}},xw=class{constructor(e){this.Ls=null,this.Yh=e}Tt(){let e=this.Yh.renderer();if(e===null)return null;if(this.Ls?.Kh===e)return this.Ls.Gh;let t=new bw(e);return this.Ls={Kh:e,Gh:t},t}Zh(){return this.Yh.zOrder?.()??`normal`}},Sw=class{constructor(e){this.Xh=null,this.Jh=e}Qh(){return this.Jh}Nn(){this.Jh.updateAllViews?.()}jn(){let e=this.Jh.paneViews?.()??[];if(this.Xh?.Kh===e)return this.Xh.Gh;let t=e.map((e=>new xw(e)));return this.Xh={Kh:e,Gh:t},t}Qs(e,t){return this.Jh.hitTest?.(e,t)??null}},Cw=class extends Sw{cn(){return[]}},ww=class{constructor(e){this.jh=e}st(e,t,n){this.jh.draw(e,yw)}qh(e,t,n){this.jh.drawBackground?.(e,yw)}},Tw=class{constructor(e){this.Ls=null,this.Yh=e}Tt(){let e=this.Yh.renderer();if(e===null)return null;if(this.Ls?.Kh===e)return this.Ls.Gh;let t=new ww(e);return this.Ls={Kh:e,Gh:t},t}Zh(){return this.Yh.zOrder?.()??`normal`}};function Ew(e){return{ri:e.text(),Ei:e.coordinate(),Vi:e.fixedCoordinate?.(),R:e.textColor(),Z:e.backColor(),It:e.visible?.()??!0,pi:e.tickVisible?.()??!0}}var Dw=class{constructor(e,t){this.Xt=new OC,this.ta=e,this.ia=t}Tt(){return this.Xt.ht({nn:this.ia.nn(),...Ew(this.ta)}),this.Xt}},Ow=class extends TC{constructor(e,t){super(),this.ta=e,this.Ki=t}Yi(e,t,n){let r=Ew(this.ta);n.Z=r.Z,e.R=r.R;let i=2/12*this.Ki.P();n.Ti=i,n.Ri=i,n.Ei=r.Ei,n.Vi=r.Vi,e.ri=r.ri,e.It=r.It,e.pi=r.pi}},kw=class extends Sw{constructor(e,t){super(e),this.na=null,this.sa=null,this.ea=null,this.ra=null,this.Te=t}dn(){let e=this.Jh.timeAxisViews?.()??[];if(this.na?.Kh===e)return this.na.Gh;let t=this.Te.Qt().Et(),n=e.map((e=>new Dw(e,t)));return this.na={Kh:e,Gh:n},n}qn(){let e=this.Jh.priceAxisViews?.()??[];if(this.sa?.Kh===e)return this.sa.Gh;let t=this.Te.Ft(),n=e.map((e=>new Ow(e,t)));return this.sa={Kh:e,Gh:n},n}ha(){let e=this.Jh.priceAxisPaneViews?.()??[];if(this.ea?.Kh===e)return this.ea.Gh;let t=e.map((e=>new Tw(e)));return this.ea={Kh:e,Gh:t},t}aa(){let e=this.Jh.timeAxisPaneViews?.()??[];if(this.ra?.Kh===e)return this.ra.Gh;let t=e.map((e=>new Tw(e)));return this.ra={Kh:e,Gh:t},t}la(e,t){return this.Jh.autoscaleInfo?.(e,t)??null}};function Aw(e,t,n,r){e.forEach((e=>{t(e).forEach((e=>{e.Zh()===n&&r.push(e)}))}))}function jw(e){return e.jn()}function Mw(e){return e.ha()}function Nw(e){return e.aa()}var Pw=[`Area`,`Line`,`Baseline`],Fw=class extends cw{constructor(e,t,n,r,i){super(e),this.qt=vw(),this.dr=new ZC(this),this.oa=[],this._a=new qC(this),this.ua=null,this.ca=null,this.da=null,this.fa=[],this.pa=new sw,this.va=new Map,this.ma=null,this.yn=n,this.wa=t;let a=new QC(this);if(this.mn=[a],this.pr=new WC(a,this,e),Pw.includes(this.wa)&&(this.ua=new XC(this)),this.Ma(),this.Yh=r(this,this.Qt(),i),this.wa===`Custom`){let e=this.Yh;e.ga&&this.ba(e.ga)}}m(){this.da!==null&&clearTimeout(this.da)}We(e){return this.yn.priceLineColor||e}Ae(e){let t={Le:!0},n=this.Ft();if(this.Qt().Et().Zi()||n.Zi()||this.qt.Zi())return t;let r=this.Qt().Et().Ee(),i=this.Lt();if(r===null||i===null)return t;let a,o;if(e){let e=this.qt.kh();if(e===null)return t;a=e,o=e.$n}else{let e=this.qt.Hn(r.bi(),-1);if(e===null||(a=this.qt.Mh(e.$n),a===null))return t;o=e.$n}let s=a.Wt[3],c=this.Sa().Sh(o,{Wt:a}),l=n.Nt(s,i.Wt);return{Le:!1,Mt:s,ri:n.Ji(s,i.Wt),qe:n.xa(s),Ye:n.Ca(s,i.Wt),R:c.sh,Ei:l,$n:o}}Sa(){return this.ca!==null||(this.ca=new uw(this)),this.ca}N(){return this.yn}vr(e){let t=this.Qt(),{priceScaleId:n,visible:r,priceFormat:i}=e;n!==void 0&&n!==this.yn.priceScaleId&&t.ya(this,n),r!==void 0&&r!==this.yn.visible&&t.Pa();let a=e.conflationThresholdFactor!==void 0;ZS(this.yn,e),Object.prototype.hasOwnProperty.call(e,`autoscaleInfoProvider`)&&e.autoscaleInfoProvider===void 0&&(this.yn.autoscaleInfoProvider=void 0),a&&(this.va.clear(),this.Qt().mr()),i!==void 0&&(this.Ma(),t.ka()),t.Ta(this),t.Ra(),this.Yh.Pt(`options`)}ht(e,t){this.qt.ht(e),this.va.clear();let n=this.Qt().Et().N();n.enableConflation&&n.precomputeConflationOnInit&&this.Da(n.precomputeConflationPriority),this.Ia(),this.ua!==null&&(t&&t.Va?this.ua.De():e.length===0&&this.ua.Re());let r=this.Qt().Ks(this);this.Qt().Ba(r),this.Qt().Ta(this),this.Qt().Ra(),this.Qt().mr()}Ia(){this.Yh.Pt(`data`)}Ea(e){let t=new ow(this,e);return this.oa.push(t),this.Qt().Ta(this),t}Aa(e){let t=this.oa.indexOf(e);t!==-1&&this.oa.splice(t,1),this.Qt().Ta(this)}La(){return this.oa}bh(){return this.wa}Lt(){let e=this.za();return e===null?null:{Wt:e.Wt[3],Oa:e.wt}}za(){let e=this.Qt().Et().Ee();if(e===null)return null;let t=e.Na();return this.qt.Hn(t,1)}Un(){return this.qt}ba(e){this.ma=e,this.va.clear()}Fa(){return!!this.Qt().Et().N().enableConflation&&this.Wa()>1}Rr(e){if(!this.Fa())return;let t=this.Wa();if(!this.va.has(t))return;let n=this.wa===`Custom`,r=n&&this.ma||void 0,i=n&&this.Yh.Ha?e=>{let t=e,n=this.Yh.Ha(t);return Array.isArray(n)?n:[typeof n==`number`?n:0]}:void 0,a=this.pa.Rr(this.qt.Bh(),e,t,r,n,i),o=vw();o.ht(a),this.va.set(t,o)}Ua(){let e=this.Qt().Et().N().enableConflation;if(this.wa===`Custom`&&this.ma===null||!e)return this.qt;let t=this.Wa();return this.va.get(t)||(this.$a(t),this.va.get(t)??this.qt)}ja(e){let t=this.qt.Mh(e);return t===null?null:this.wa===`Bar`||this.wa===`Candlestick`||this.wa===`Custom`?{jr:t.Wt[0],qr:t.Wt[1],Yr:t.Wt[2],Kr:t.Wt[3]}:t.Wt[3]}qa(e){let t=[];Aw(this.fa,jw,`top`,t);let n=this.ua;return n!==null&&n.It()&&(this.da===null&&n.Ve()&&(this.da=setTimeout((()=>{this.da=null,this.Qt().Ya()}),0)),n.Ie(),t.unshift(n)),t}jn(){let e=[];this.Ka()||e.push(this._a),e.push(this.Yh,this.dr);let t=this.oa.map((e=>e.wr()));return e.push(...t),Aw(this.fa,jw,`normal`,e),e}Ga(){let e=this.Yh.Ga?.()??null;if(e===null)return null;let t=[];this.Ka()||t.push(this._a),t.push(...e.Za),Aw(this.fa,jw,`normal`,t);let n=[];n.push(...e.qa,this.dr);let r=this.oa.map((e=>e.wr()));return n.push(...r),{Za:t,qa:n}}Xa(){return this.Ja(jw,`bottom`)}Qa(e){return this.Ja(Mw,e)}tl(e){return this.Ja(Nw,e)}il(e,t){return this.fa.map((n=>n.Qs(e,t))).filter((e=>e!==null))}cn(){return[this.pr,...this.oa.map((e=>e.Mr()))]}qn(e,t){if(t!==this.hn&&!this.Ka())return[];let n=[...this.mn];for(let e of this.oa)n.push(e.gr());return this.fa.forEach((e=>{n.push(...e.qn())})),n}dn(){let e=[];return this.fa.forEach((t=>{e.push(...t.dn())})),e}la(e,t){if(this.yn.autoscaleInfoProvider!==void 0){let n=this.yn.autoscaleInfoProvider((()=>{let n=this.nl(e,t);return n===null?null:n.sr()}));return tw.er(n)}return this.nl(e,t)}Kh(){let e=this.yn.priceFormat;return e.base??1/e.minMove}sl(){return this.el}Nn(){this.Yh.Pt();for(let e of this.mn)e.Pt();for(let e of this.oa)e.Pt();this.dr.Pt(),this._a.Pt(),this.ua?.Pt(),this.fa.forEach((e=>e.Nn()))}Ft(){return $(super.Ft())}At(e){if(this.wa!==`Line`&&this.wa!==`Area`&&this.wa!==`Baseline`||!this.yn.crosshairMarkerVisible)return null;let t=this.qt.Mh(e);return t===null?null:{Mt:t.Wt[3],ft:this.rl(),Ht:this.hl(),Ot:this.al(),zt:this.ll(e)}}He(){return this.yn.title}It(){return this.yn.visible}ol(e){this.fa.push(new kw(e,this))}_l(e){this.fa=this.fa.filter((t=>t.Qh()!==e))}ul(){if(this.wa===`Custom`)return e=>this.Yh.Ha(e)}cl(){if(this.wa===`Custom`)return e=>this.Yh.dl(e)}fl(){return this.qt.Lh()}Ka(){return!NC(this.Ft().pl())}nl(e,t){if(!$S(e)||!$S(t)||this.qt.Zi())return null;let n=this.wa===`Line`||this.wa===`Area`||this.wa===`Baseline`||this.wa===`Histogram`?[3]:[2,1],r=this.qt.Eh(e,t,n),i=r===null?null:new ew(r.Uh,r.$h),a=null;if(this.bh()===`Histogram`){let e=this.yn.base,t=new ew(e,e);i=i===null?t:i.Ss(t)}return this.fa.forEach((n=>{let r=n.la(e,t);if(r?.priceRange){let e=new ew(r.priceRange.minValue,r.priceRange.maxValue);i=i===null?e:i.Ss(e)}r?.margins&&(a=r.margins)})),new tw(i,a)}rl(){switch(this.wa){case`Line`:case`Area`:case`Baseline`:return this.yn.crosshairMarkerRadius}return 0}hl(){switch(this.wa){case`Line`:case`Area`:case`Baseline`:{let e=this.yn.crosshairMarkerBorderColor;if(e.length!==0)return e}}return null}al(){switch(this.wa){case`Line`:case`Area`:case`Baseline`:return this.yn.crosshairMarkerBorderWidth}return 0}ll(e){switch(this.wa){case`Line`:case`Area`:case`Baseline`:{let e=this.yn.crosshairMarkerBackgroundColor;if(e.length!==0)return e}}return this.Sa().Sh(e).sh}Ma(){switch(this.yn.priceFormat.type){case`custom`:{let e=this.yn.priceFormat.formatter;this.el={format:e,formatTickmarks:this.yn.priceFormat.tickmarksFormatter??(t=>t.map(e))};break}case`volume`:this.el=new BC(this.yn.priceFormat.precision);break;case`percent`:this.el=new zC(this.yn.priceFormat.precision);break;default:{let e=10**this.yn.priceFormat.precision;this.el=new RC(e,this.yn.priceFormat.minMove*e)}}this.hn!==null&&this.hn.vl()}Ja(e,t){let n=[];return Aw(this.fa,e,t,n),n}Wa(){let{ml:e,wl:t,Ml:n}=this.gl();return this.pa.Sr(e,t,n)}gl(){let e=this.Qt().Et(),t=e.ml(),n=window.devicePixelRatio||1,r=e.N().conflationThresholdFactor;return{ml:t,wl:n,Ml:this.yn.conflationThresholdFactor??r??1}}bl(e){let t=this.qt.Bh(),n;if(this.wa===`Custom`&&this.ma!==null){let r=this.ul();if(!r)throw Error(rw);n=this.pa.Cr(t,e,this.ma,!0,(e=>r(e)))}else n=this.pa.Cr(t,e);let r=vw();return r.ht(n),r}$a(e){let t=this.bl(e);this.va.set(e,t)}Da(e){if(this.wa===`Custom`&&(this.ma===null||!this.ul()))return;this.va.clear();let t=this.Qt().Et().Sl();for(let n of t){let t=()=>{this.xl(n)},r=typeof window==`object`&&window||typeof self==`object`&&self;r?.yl?.Cl?r.yl.Cl((()=>{t()}),{se:e}):Promise.resolve().then((()=>t()))}}xl(e){if(this.va.has(e)||this.qt.Bh().length===0)return;let t=this.bl(e);this.va.set(e,t)}},Iw=[3],Lw=[0,1,2,3],Rw=class{constructor(e){this.yn=e}Pl(e,t,n){let r=e;if(this.yn.mode===0)return r;let i=n.kn(),a=i.Lt();if(a===null)return r;let o=i.Nt(e,a),s=n.kl().filter((e=>e instanceof Fw)).reduce(((e,r)=>{if(n.Gs(r)||!r.It())return e;let i=r.Ft(),a=r.Un();if(i.Zi()||!a.ze(t))return e;let o=a.Mh(t);if(o===null)return e;let s=YS(r.Lt()),c=this.yn.mode===3?Lw:Iw;return e.concat(c.map((e=>i.Nt(o.Wt[e],s.Wt))))}),[]);if(s.length===0)return r;s.sort(((e,t)=>Math.abs(e-o)-Math.abs(t-o)));let c=s[0];return r=i.Tn(c,a),r}};function zw(e,t,n){return Math.min(Math.max(e,t),n)}function Bw(e,t,n){return t-e<=n}var Vw=class extends fC{constructor(){super(...arguments),this.qt=null}ht(e){this.qt=e}et({context:e,bitmapSize:t,horizontalPixelRatio:n,verticalPixelRatio:r}){if(this.qt===null)return;let i=Math.max(1,Math.floor(n));e.lineWidth=i,function(e,t){e.save(),e.lineWidth%2&&e.translate(.5,.5),t(),e.restore()}(e,(()=>{let a=$(this.qt);if(a.Tl){e.strokeStyle=a.Rl,GS(e,a.Dl),e.beginPath();for(let r of a.Il){let a=Math.round(r.Vl*n);e.moveTo(a,-i),e.lineTo(a,t.height+i)}e.stroke()}if(a.Bl){e.strokeStyle=a.El,GS(e,a.Al),e.beginPath();for(let n of a.Ll){let a=Math.round(n.Vl*r);e.moveTo(-i,a),e.lineTo(t.width+i,a)}e.stroke()}}))}},Hw=class{constructor(e){this.Xt=new Vw,this.xt=!0,this.yt=e}Pt(){this.xt=!0}Tt(){if(this.xt){let e=this.yt.Qt().N().grid,t={Bl:e.horzLines.visible,Tl:e.vertLines.visible,El:e.horzLines.color,Rl:e.vertLines.color,Al:e.horzLines.style,Dl:e.vertLines.style,Ll:this.yt.kn().zl(),Il:(this.yt.Qt().Et().zl()||[]).map((e=>({Vl:e.coord})))};this.Xt.ht(t),this.xt=!1}return this.Xt}},Uw=class{constructor(e){this.Yh=new Hw(e)}wr(){return this.Yh}},Ww={Ol:4,Nl:1e-4};function Gw(e,t){let n=100*(e-t)/t;return t<0?-n:n}function Kw(e,t){return new ew(Gw(e.Je(),t),Gw(e.Qe(),t))}function qw(e,t){let n=100*(e-t)/t+100;return t<0?-n:n}function Jw(e,t){return new ew(qw(e.Je(),t),qw(e.Qe(),t))}function Yw(e,t){let n=Math.abs(e);if(n<1e-15)return 0;let r=Math.log10(n+t.Nl)+t.Ol;return e<0?-r:r}function Xw(e,t){let n=Math.abs(e);if(n<1e-15)return 0;let r=10**(n-t.Ol)-t.Nl;return e<0?-r:r}function Zw(e,t){return e===null?null:new ew(Yw(e.Je(),t),Yw(e.Qe(),t))}function Qw(e,t){return e===null?null:new ew(Xw(e.Je(),t),Xw(e.Qe(),t))}function $w(e){if(e===null)return Ww;let t=Math.abs(e.Qe()-e.Je());if(t>=1||t<1e-15)return Ww;let n=Math.ceil(Math.abs(Math.log10(t))),r=Ww.Ol+n;return{Ol:r,Nl:1/10**r}}var eT=class{constructor(e,t){if(this.Fl=e,this.Wl=t,function(e){if(e<0)return!1;if(e>0xde0b6b3a7640000)return!0;for(let t=e;t>1;t/=10)if(t%10!=0)return!1;return!0}(this.Fl))this.Hl=[2,2.5,2];else{this.Hl=[];for(let e=this.Fl;e!==1;){if(e%2==0)this.Hl.push(2),e/=2;else{if(e%5!=0)throw Error(`unexpected base`);this.Hl.push(2,2.5),e/=5}if(this.Hl.length>100)throw Error(`something wrong with base`)}}}Ul(e,t,n){let r=this.Fl===0?0:1/this.Fl,i=10**Math.max(0,Math.ceil(Math.log10(e-t))),a=0,o=this.Wl[0];for(;;){let e=Bw(i,r,1e-14)&&i>r+1e-14,t=Bw(i,n*o,1e-14),s=Bw(i,1,1e-14);if(!(e&&t&&s))break;i/=o,o=this.Wl[++a%this.Wl.length]}if(i<=r+1e-14&&(i=r),i=Math.max(1,i),this.Hl.length>0&&(s=i,c=1,l=1e-14,Math.abs(s-c)<l))for(a=0,o=this.Hl[0];Bw(i,n*o,1e-14)&&i>r+1e-14;)i/=o,o=this.Hl[++a%this.Hl.length];var s,c,l;return i}},tT=class{constructor(e,t,n,r){this.$l=[],this.Ki=e,this.Fl=t,this.jl=n,this.ql=r}Ul(e,t){if(e<t)throw Error(`high < low`);let n=this.Ki.$t(),r=(e-t)*this.Yl()/n,i=new eT(this.Fl,[2,2.5,2]),a=new eT(this.Fl,[2,2,2.5]),o=new eT(this.Fl,[2.5,2,2]),s=[];return s.push(i.Ul(e,t,r),a.Ul(e,t,r),o.Ul(e,t,r)),function(e){if(e.length<1)throw Error(`array is empty`);let t=e[0];for(let n=1;n<e.length;++n)e[n]<t&&(t=e[n]);return t}(s)}Kl(){let e=this.Ki,t=e.Lt();if(t===null)return void(this.$l=[]);let n=e.$t(),r=this.jl(n-1,t),i=this.jl(0,t),a=this.Ki.N().entireTextOnly?this.Gl()/2:0,o=a,s=n-1-a,c=Math.max(r,i),l=Math.min(r,i);if(c===l)return void(this.$l=[]);let u=this.Ul(c,l);if(this.Zl(t,u,c,l,o,s),e.Xl()&&this.Jl(u,l,c)){let e=this.Ki.Ql();this.io(t,u,o,s,e,2*e)}let d=this.$l.map((e=>e.no)),f=this.Ki.so(d);for(let e=0;e<this.$l.length;e++)this.$l[e].eo=f[e]}zl(){return this.$l}Gl(){return this.Ki.P()}Yl(){return Math.ceil(this.Gl()*this.Ki.N().tickMarkDensity)}Zl(e,t,n,r,i,a){let o=this.$l,s=this.Ki,c=n%t;c+=c<0?t:0;let l=n>=r?1:-1,u=null,d=0;for(let f=n-c;f>r;f-=t){let n=this.ql(f,e,!0);u!==null&&Math.abs(n-u)<this.Yl()||n<i||n>a||(d<o.length?(o[d].Vl=n,o[d].eo=s.ro(f),o[d].no=f):o.push({Vl:n,eo:s.ro(f),no:f}),d++,u=n,s.ho()&&(t=this.Ul(f*l,r)))}o.length=d}io(e,t,n,r,i,a){let o=this.$l,s=this.ao(e,n,i,a),c=this.ao(e,r,-a,-i),l=this.ql(0,e,!0)-this.ql(t,e,!0);o.length>0&&o[0].Vl-s.Vl<l/2&&o.shift(),o.length>0&&c.Vl-o[o.length-1].Vl<l/2&&o.pop(),o.unshift(s),o.push(c)}ao(e,t,n,r){let i=(n+r)/2,a=this.jl(t+n,e),o=this.jl(t+r,e),s=Math.min(a,o),c=Math.max(a,o),l=Math.max(.1,this.Ul(c,s)),u=this.jl(t+i,e),d=u-u%l,f=this.ql(d,e,!0);return{eo:this.Ki.ro(d),Vl:f,no:d}}Jl(e,t,n){let r=YS(this.Ki.ar());return this.Ki.ho()&&(r=Qw(r,this.Ki.lo())),r.Je()-t<e&&n-r.Qe()<e}};function nT(e){return e.slice().sort(((e,t)=>$(e.ln())-$(t.ln())))}var rT;(function(e){e[e.Normal=0]=`Normal`,e[e.Logarithmic=1]=`Logarithmic`,e[e.Percentage=2]=`Percentage`,e[e.IndexedTo100=3]=`IndexedTo100`})(rT||={});var iT=new zC,aT=new RC(100,1),oT=class{constructor(e,t,n,r,i){this.oo=0,this._o=null,this.rr=null,this.uo=null,this.co={do:!1,fo:null},this.po=!1,this.vo=0,this.mo=0,this.wo=new XS,this.Mo=new XS,this.bo=[],this.So=null,this.xo=null,this.Co=null,this.yo=null,this.Po=null,this.el=aT,this.ko=$w(null),this.To=e,this.yn=t,this.Ro=n,this.Do=r,this.Io=i,this.Vo=new tT(this,100,this.Bo.bind(this),this.Eo.bind(this))}pl(){return this.To}N(){return this.yn}vr(e){if(ZS(this.yn,e),this.vl(),e.mode!==void 0&&this.Ao({_e:e.mode}),e.scaleMargins!==void 0){let t=JS(e.scaleMargins.top),n=JS(e.scaleMargins.bottom);if(t<0||t>1)throw Error(`Invalid top margin - expect value between 0 and 1, given=${t}`);if(n<0||n>1)throw Error(`Invalid bottom margin - expect value between 0 and 1, given=${n}`);if(t+n>1)throw Error(`Invalid margins - sum of margins must be less than 1, given=${t+n}`);this.Lo(),this.Co=null}}zo(){return this.yn.autoScale}Oo(){return this.po}ho(){return this.yn.mode===1}je(){return this.yn.mode===2}No(){return this.yn.mode===3}lo(){return this.ko}_e(){return{hs:this.yn.autoScale,Fo:this.yn.invertScale,_e:this.yn.mode}}Ao(e){let t=this._e(),n=null;e.hs!==void 0&&(this.yn.autoScale=e.hs),e._e!==void 0&&(this.yn.mode=e._e,e._e!==2&&e._e!==3||(this.yn.autoScale=!0),this.co.do=!1),t._e===1&&e._e!==t._e&&(function(e,t){if(e===null)return!1;let n=Xw(e.Je(),t),r=Xw(e.Qe(),t);return isFinite(n)&&isFinite(r)}(this.rr,this.ko)?(n=Qw(this.rr,this.ko),n!==null&&this.Wo(n)):this.yn.autoScale=!0),e._e===1&&e._e!==t._e&&(n=Zw(this.rr,this.ko),n!==null&&this.Wo(n));let r=t._e!==this.yn.mode;r&&(t._e===2||this.je())&&this.vl(),r&&(t._e===3||this.No())&&this.vl(),e.Fo!==void 0&&t.Fo!==e.Fo&&(this.yn.invertScale=e.Fo,this.Ho()),this.Mo.p(t,this._e())}Uo(){return this.Mo}P(){return this.Ro.fontSize}$t(){return this.oo}$o(e){this.oo!==e&&(this.oo=e,this.Lo(),this.Co=null)}jo(){if(this._o)return this._o;let e=this.$t()-this.qo()-this.Yo();return this._o=e,e}ar(){return this.Ko(),this.rr}Wo(e,t){let n=this.rr;(t||n===null&&e!==null||n!==null&&!n.Ze(e))&&(this.Co=null,this.rr=e)}Go(e){this.Wo(e),this.Zo(e!==null)}Zi(){return this.Ko(),this.oo===0||!this.rr||this.rr.Zi()}Xo(e){return this.Fo()?e:this.$t()-1-e}Nt(e,t){return this.je()?e=Gw(e,t):this.No()&&(e=qw(e,t)),this.Eo(e,t)}Jo(e,t,n){this.Ko();let r=this.Yo(),i=$(this.ar()),a=i.Je(),o=i.Qe(),s=this.jo()-1,c=this.Fo(),l=s/(o-a),u=n===void 0?0:n.from,d=n===void 0?e.length:n.to,f=this.Qo();for(let n=u;n<d;n++){let i=e[n],o=i.Mt;if(isNaN(o))continue;let s=o;f!==null&&(s=f(i.Mt,t));let u=r+l*(s-a);i.ut=c?u:this.oo-1-u}}t_(e,t,n){this.Ko();let r=this.Yo(),i=$(this.ar()),a=i.Je(),o=i.Qe(),s=this.jo()-1,c=this.Fo(),l=s/(o-a),u=n===void 0?0:n.from,d=n===void 0?e.length:n.to,f=this.Qo();for(let n=u;n<d;n++){let i=e[n],o=i.jr,s=i.qr,u=i.Yr,d=i.Kr;f!==null&&(o=f(i.jr,t),s=f(i.qr,t),u=f(i.Yr,t),d=f(i.Kr,t));let p=r+l*(o-a),m=c?p:this.oo-1-p;i.i_=m,p=r+l*(s-a),m=c?p:this.oo-1-p,i.n_=m,p=r+l*(u-a),m=c?p:this.oo-1-p,i.s_=m,p=r+l*(d-a),m=c?p:this.oo-1-p,i.e_=m}}Tn(e,t){let n=this.Bo(e,t);return this.r_(n,t)}r_(e,t){let n=e;return this.je()?n=function(e,t){return t<0&&(e=-e),e/100*t+t}(n,t):this.No()&&(n=function(e,t){return e-=100,t<0&&(e=-e),e/100*t+t}(n,t)),n}kl(){return this.bo}Dt(){return this.xo||=nT(this.bo),this.xo}h_(e){this.bo.indexOf(e)===-1&&(this.bo.push(e),this.vl(),this.a_())}l_(e){let t=this.bo.indexOf(e);if(t===-1)throw Error(`source is not attached to scale`);this.bo.splice(t,1),this.bo.length===0&&(this.Ao({hs:!0}),this.Wo(null)),this.vl(),this.a_()}Lt(){let e=null;for(let t of this.bo){let n=t.Lt();n!==null&&(e===null||n.Oa<e.Oa)&&(e=n)}return e===null?null:e.Wt}Fo(){return this.yn.invertScale}zl(){let e=this.Lt()===null;if(this.Co!==null&&(e||this.Co.o_===e))return this.Co.zl;this.Vo.Kl();let t=this.Vo.zl();return this.Co={zl:t,o_:e},this.wo.p(),t}__(){return this.wo}u_(e){this.je()||this.No()||this.yo===null&&this.uo===null&&(this.Zi()||(this.yo=this.oo-e,this.uo=$(this.ar()).Xe()))}c_(e){if(this.je()||this.No()||this.yo===null)return;this.Ao({hs:!1}),(e=this.oo-e)<0&&(e=0);let t=(this.yo+.2*(this.oo-1))/(e+.2*(this.oo-1)),n=$(this.uo).Xe();t=Math.max(t,.1),n.ir(t),this.Wo(n)}d_(){this.je()||this.No()||(this.yo=null,this.uo=null)}f_(e){this.zo()||this.Po===null&&this.uo===null&&(this.Zi()||(this.Po=e,this.uo=$(this.ar()).Xe()))}p_(e){if(this.zo()||this.Po===null)return;let t=$(this.ar()).tr()/(this.jo()-1),n=e-this.Po;this.Fo()&&(n*=-1);let r=n*t,i=$(this.uo).Xe();i.nr(r),this.Wo(i,!0),this.Co=null}v_(){this.zo()||this.Po!==null&&(this.Po=null,this.uo=null)}sl(){return this.el||this.vl(),this.el}Ji(e,t){switch(this.yn.mode){case 2:return this.m_(Gw(e,t));case 3:return this.sl().format(qw(e,t));default:return this.cr(e)}}ro(e){switch(this.yn.mode){case 2:return this.m_(e);case 3:return this.sl().format(e);default:return this.cr(e)}}so(e){switch(this.yn.mode){case 2:return this.w_(e);case 3:return this.sl().formatTickmarks(e);default:return this.M_(e)}}xa(e){return this.cr(e,$(this.So).sl())}Ca(e,t){return e=Gw(e,t),this.m_(e,iT)}g_(){return this.bo}b_(e){this.co={fo:e,do:!1}}Nn(){this.bo.forEach((e=>e.Nn()))}Xl(){return this.yn.ensureEdgeTickMarksVisible&&this.zo()}Ql(){return this.P()/2}vl(){this.Co=null;let e=1/0;this.So=null;for(let t of this.bo)t.ln()<e&&(e=t.ln(),this.So=t);let t=100;this.So!==null&&(t=Math.round(this.So.Kh())),this.el=aT,this.je()?(this.el=iT,t=100):this.No()?(this.el=new RC(100,1),t=100):this.So!==null&&(this.el=this.So.sl()),this.Vo=new tT(this,t,this.Bo.bind(this),this.Eo.bind(this)),this.Vo.Kl()}a_(){this.xo=null}S_(){return this.So===null||this.je()||this.No()?1:1/this.So.Kh()}Xi(){return this.Io}Zo(e){this.po=e}qo(){return this.Fo()?this.yn.scaleMargins.bottom*this.$t()+this.mo:this.yn.scaleMargins.top*this.$t()+this.vo}Yo(){return this.Fo()?this.yn.scaleMargins.top*this.$t()+this.vo:this.yn.scaleMargins.bottom*this.$t()+this.mo}Ko(){this.co.do||(this.co.do=!0,this.x_())}Lo(){this._o=null}Eo(e,t){if(this.Ko(),this.Zi())return 0;e=this.ho()&&e?Yw(e,this.ko):e;let n=$(this.ar()),r=this.Yo()+(this.jo()-1)*(e-n.Je())/n.tr();return this.Xo(r)}Bo(e,t){if(this.Ko(),this.Zi())return 0;let n=this.Xo(e),r=$(this.ar()),i=r.Je()+r.tr()*((n-this.Yo())/(this.jo()-1));return this.ho()?Xw(i,this.ko):i}Ho(){this.Co=null,this.Vo.Kl()}x_(){if(this.Oo()&&!this.zo())return;let e=this.co.fo;if(e===null)return;let t=null,n=this.g_(),r=0,i=0;for(let a of n){if(!a.It())continue;let n=a.Lt();if(n===null)continue;let o=a.la(e.Na(),e.bi()),s=o&&o.ar();if(s!==null){switch(this.yn.mode){case 1:s=Zw(s,this.ko);break;case 2:s=Kw(s,n.Wt);break;case 3:s=Jw(s,n.Wt)}if(t=t===null?s:t.Ss($(s)),o!==null){let e=o.lr();e!==null&&(r=Math.max(r,e.above),i=Math.max(i,e.below))}}}if(this.Xl()&&(r=Math.max(r,this.Ql()),i=Math.max(i,this.Ql())),r===this.vo&&i===this.mo||(this.vo=r,this.mo=i,this.Co=null,this.Lo()),t!==null){if(t.Je()===t.Qe()){let e=5*this.S_();this.ho()&&(t=Qw(t,this.ko)),t=new ew(t.Je()-e,t.Qe()+e),this.ho()&&(t=Zw(t,this.ko))}if(this.ho()){let e=Qw(t,this.ko),n=$w(e);if(a=n,o=this.ko,a.Ol!==o.Ol||a.Nl!==o.Nl){let r=this.uo===null?null:Qw(this.uo,this.ko);this.ko=n,t=Zw(e,n),r!==null&&(this.uo=Zw(r,n))}}this.Wo(t)}else this.rr===null&&(this.Wo(new ew(-.5,.5)),this.ko=$w(null));var a,o}Qo(){return this.je()?Gw:this.No()?qw:this.ho()?e=>Yw(e,this.ko):null}C_(e,t,n){return t===void 0?(n===void 0&&(n=this.sl()),n.format(e)):t(e)}y_(e,t,n){return t===void 0?(n===void 0&&(n=this.sl()),n.formatTickmarks(e)):t(e)}cr(e,t){return this.C_(e,this.Do.priceFormatter,t)}M_(e,t){let n=this.Do.priceFormatter;return this.y_(e,this.Do.tickmarksPriceFormatter??(n?e=>e.map(n):void 0),t)}m_(e,t){return this.C_(e,this.Do.percentageFormatter,t)}w_(e,t){let n=this.Do.percentageFormatter;return this.y_(e,this.Do.tickmarksPercentageFormatter??(n?e=>e.map(n):void 0),t)}};function sT(e){return e instanceof Fw}var cT=class{constructor(e,t){this.bo=[],this.P_=new Map,this.oo=0,this.k_=0,this.T_=1,this.xo=null,this.R_=null,this.D_=!1,this.I_=new XS,this.fa=[],this.ia=e,this.sn=t,this.V_=new Uw(this);let n=t.N();this.B_=this.E_(`left`,n.leftPriceScale),this.A_=this.E_(`right`,n.rightPriceScale),this.B_.Uo().i(this.L_.bind(this,this.B_),this),this.A_.Uo().i(this.L_.bind(this,this.A_),this),this.z_(n)}z_(e){if(e.leftPriceScale&&this.B_.vr(e.leftPriceScale),e.rightPriceScale&&this.A_.vr(e.rightPriceScale),e.localization&&(this.B_.vl(),this.A_.vl()),e.overlayPriceScales){let t=Array.from(this.P_.values());for(let n of t){let t=$(n[0].Ft());t.vr(e.overlayPriceScales),e.localization&&t.vl()}}}O_(e){switch(e){case`left`:return this.B_;case`right`:return this.A_}return this.P_.has(e)?JS(this.P_.get(e))[0].Ft():null}m(){this.Qt().N_().u(this),this.B_.Uo().u(this),this.A_.Uo().u(this),this.bo.forEach((e=>{e.m&&e.m()})),this.fa=this.fa.filter((e=>{let t=e.Qh();return t.detached&&t.detached(),!1})),this.I_.p()}F_(){return this.T_}W_(e){this.T_=e}Qt(){return this.sn}nn(){return this.k_}$t(){return this.oo}H_(e){this.k_=e,this.U_()}$o(e){this.oo=e,this.B_.$o(e),this.A_.$o(e),this.bo.forEach((t=>{if(this.Gs(t)){let n=t.Ft();n!==null&&n.$o(e)}})),this.U_()}j_(e){this.D_=e}q_(){return this.D_}Y_(){return this.bo.filter(sT)}kl(){return this.bo}Gs(e){let t=e.Ft();return t===null||this.B_!==t&&this.A_!==t}h_(e,t,n){this.K_(e,t,n?e.ln():this.bo.length)}l_(e,t){let n=this.bo.indexOf(e);qS(n!==-1,`removeDataSource: invalid data source`),this.bo.splice(n,1),t||this.bo.forEach(((e,t)=>e._n(t)));let r=$(e.Ft()).pl();if(this.P_.has(r)){let t=JS(this.P_.get(r)),n=t.indexOf(e);n!==-1&&(t.splice(n,1),t.length===0&&this.P_.delete(r))}let i=e.Ft();i&&i.kl().indexOf(e)>=0&&(i.l_(e),this.G_(i)),this.Z_()}Xs(e){return e===this.B_?`left`:e===this.A_?`right`:`overlay`}X_(){return this.B_}J_(){return this.A_}Q_(e,t){e.u_(t)}tu(e,t){e.c_(t),this.U_()}iu(e){e.d_()}nu(e,t){e.f_(t)}su(e,t){e.p_(t),this.U_()}eu(e){e.v_()}U_(){this.bo.forEach((e=>{e.Nn()}))}kn(){let[e,t]=this.ru(),n=null;return e.N().visible&&e.kl().length!==0?n=e:t.N().visible&&t.kl().length!==0?n=t:this.bo.length!==0&&(n=this.bo[0].Ft()),n===null&&(n=this.Zs()??e),n}Zs(){let[e,t]=this.ru();return e.N().visible?e:t.N().visible?t:null}G_(e){e!==null&&e.zo()&&this.hu(e)}au(e){let t=this.ia.Ee();e.Ao({hs:!0}),t!==null&&e.b_(t),this.U_()}lu(){this.hu(this.B_),this.hu(this.A_)}ou(){this.G_(this.B_),this.G_(this.A_),this.bo.forEach((e=>{this.Gs(e)&&this.G_(e.Ft())})),this.U_(),this.sn.mr()}Dt(){return this.xo===null&&(this.xo=nT(this.bo)),this.xo}_u(){let e=this.Dt(),t=this.sn.cu()?.uu,n=this.sn.N().hoveredSeriesOnTop,r=this.R_;if(r!==null&&r.Kh===e&&r.du===t&&r.fu===n)return r.pu;let i=function(e,t,n){if(!n)return e;let r=e.indexOf(t);if(r===-1||r===e.length-1)return e;let i=[];for(let t=0;t<e.length;t++)t!==r&&i.push(e[t]);return i.push(e[r]),i}(e,t,n);return this.R_={Kh:e,du:t,fu:n,pu:i},i}vu(e,t){t=zw(t,0,this.bo.length-1);let n=this.bo.indexOf(e);qS(n!==-1,`setSeriesOrder: invalid data source`),this.bo.splice(n,1),this.bo.splice(t,0,e),this.bo.forEach(((e,t)=>e._n(t))),this.Z_();for(let e of[this.B_,this.A_])e.a_(),e.vl();this.sn.mr()}Vt(){return this.Dt().filter(sT)}mu(){return this.I_}wu(){return this.V_}ol(e){this.fa.push(new Cw(e))}_l(e){this.fa=this.fa.filter((t=>t.Qh()!==e)),e.detached&&e.detached(),this.sn.mr()}Mu(){return this.fa}il(e,t){return this.fa.map((n=>n.Qs(e,t))).filter((e=>e!==null))}hu(e){let t=e.g_();if(t&&t.length>0&&!this.ia.Zi()){let t=this.ia.Ee();t!==null&&e.b_(t)}e.Nn()}K_(e,t,n){let r=this.O_(t);if(r===null&&(r=this.E_(t,this.sn.N().overlayPriceScales)),this.bo.splice(n,0,e),!NC(t)){let n=this.P_.get(t)||[];n.push(e),this.P_.set(t,n)}e._n(n),r.h_(e),e.un(r),this.G_(r),this.Z_()}Z_(){this.xo=null,this.R_=null}ru(){return this.sn.N().defaultVisiblePriceScaleId===`left`?[this.B_,this.A_]:[this.A_,this.B_]}L_(e,t,n){t._e!==n._e&&this.hu(e)}E_(e,t){let n=new oT(e,{visible:!0,autoScale:!0,...nC(t)},this.sn.N().layout,this.sn.N().localization,this.sn.Xi());return n.$o(this.$t()),n}};function lT(e,t){return t===null||e.se===2&&t.se!==2||(t.se!==2||e.se===2)&&e.ne!==t.ne&&e.ne<t.ne}function uT(e){return{te:e.te,ie:e.ie}}function dT(e){return{ne:e.distance??0,se:e.hitTestPriority??(e.itemType===`marker`?2:0),ee:e.itemType??`primitive`,gu:e.cursorStyle,te:e.externalId}}function fT(e){return{uu:e.uu,bu:uT(e.Su),gu:e.Su.gu,ee:e.Su.ee??`primitive`}}function pT(e,t,n,r){let i=null;for(let a of e){let e=a.Qs?.(t,n,r)??null;if(e===null){let i=a.Tt(r);e=i!==null&&i.Qs?i.Qs(t,n):null}if(e!==null){let t={xu:a,Su:e};(i===null||lT(t.Su,i.Su))&&(i=t)}}return i}function mT(e){return e.jn!==void 0}function hT(e,t,n){let r=[e,...e.Dt()].reverse(),i=function(e,t,n){let r,i,a;for(let c of e){let e=c.il?.(t,n)??[];for(let t of e){let e=dT(t);o=t.zOrder,s=r?.zOrder,(!s||o===`top`&&s!==`top`||o===`normal`&&s===`bottom`||t.zOrder===r?.zOrder&&i!==void 0&&lT(e,i)||t.zOrder===r?.zOrder&&i===void 0)&&(r=t,i=e,a=c)}}var o,s;return r&&a&&i?{Su:i,Cu:r,uu:a}:null}(r,t,n);if(i?.Cu.zOrder===`top`)return fT(i);let a=null,o=null;for(let s of r){if(i&&i.uu===s&&i.Cu.zOrder!==`bottom`&&!i.Cu.isBackground)return a??fT(i);if(mT(s)){let r=pT(s.jn(e),t,n,e);if(r!==null){let e={uu:s,xu:r.xu,bu:uT(r.Su),gu:r.Su.gu,ee:r.Su.ee??`primitive`};(a===null||lT(r.Su,o))&&(a=e,o=r.Su)}}if(i&&i.uu===s&&i.Cu.zOrder!==`bottom`&&i.Cu.isBackground)return a??fT(i)}return a===null?i?.Cu?fT(i):null:a}var gT=class{constructor(e,t,n=50){this.Vs=0,this.Bs=1,this.Es=1,this.Ls=new Map,this.As=new Map,this.yu=e,this.Pu=t,this.zs=n}ku(e){let t=e.time,n=this.Pu.cacheKey(t),r=this.Ls.get(n);if(r!==void 0)return r.Tu;if(this.Vs===this.zs){let e=this.As.get(this.Es);this.As.delete(this.Es),this.Ls.delete(JS(e)),this.Es++,this.Vs--}let i=this.yu(e);return this.Ls.set(n,{Tu:i,Ws:this.Bs}),this.As.set(this.Bs,n),this.Vs++,this.Bs++,i}},_T=class{constructor(e,t){qS(e<=t,`right should be >= left`),this.Ru=e,this.Du=t}Na(){return this.Ru}bi(){return this.Du}Iu(){return this.Du-this.Ru+1}ze(e){return this.Ru<=e&&e<=this.Du}Ze(e){return this.Ru===e.Na()&&this.Du===e.bi()}};function vT(e,t){return e===null||t===null?e===t:e.Ze(t)}var yT=class{constructor(){this.Vu=new Map,this.Ls=null,this.Bu=!1}Eu(e){this.Bu=e,this.Ls=null}Au(e,t){this.Lu(t),this.Ls=null;for(let n=t;n<e.length;++n){let t=e[n],r=this.Vu.get(t.timeWeight);r===void 0&&(r=[],this.Vu.set(t.timeWeight,r)),r.push({index:n,time:t.time,weight:t.timeWeight,originalTime:t.originalTime})}}zu(e,t,n,r,i){let a=Math.ceil(t/e);return this.Ls!==null&&this.Ls.Ou===a&&i===this.Ls.Nu&&n===this.Ls.Fu||(this.Ls={Nu:i,Fu:n,zl:this.Wu(a,n,r),Ou:a}),this.Ls.zl}Lu(e){if(e===0)return void this.Vu.clear();let t=[];this.Vu.forEach(((n,r)=>{e<=n[0].index?t.push(r):n.splice(fw(n,e,(t=>t.index<e)),1/0)}));for(let e of t)this.Vu.delete(e)}Wu(e,t,n){let r=[],i=e=>!t||n.has(e.index);for(let t of Array.from(this.Vu.keys()).sort(((e,t)=>t-e))){if(!this.Vu.get(t))continue;let n=r;r=[];let a=n.length,o=0,s=JS(this.Vu.get(t)),c=s.length,l=1/0,u=-1/0;for(let t=0;t<c;t++){let c=s[t],d=c.index;for(;o<a;){let e=n[o],t=e.index;if(!(t<d&&i(e))){l=t;break}o++,r.push(e),u=t,l=1/0}if(l-d>=e&&d-u>=e&&i(c))r.push(c),u=d;else if(this.Bu)return n}for(;o<a;o++)i(n[o])&&r.push(n[o])}return r}},bT=class e{constructor(e){this.Hu=e}Uu(){return this.Hu===null?null:new _T(Math.floor(this.Hu.Na()),Math.ceil(this.Hu.bi()))}$u(){return this.Hu}static ju(){return new e(null)}};function xT(e,t){return e.weight>t.weight?e:t}var ST=class{constructor(e,t,n,r){this.k_=0,this.qu=null,this.Yu=[],this.Po=null,this.yo=null,this.Ku=new yT,this.Gu=new Map,this.Zu=bT.ju(),this.Xu=!0,this.Ju=new XS,this.Qu=new XS,this.tc=new XS,this.nc=null,this.sc=null,this.ec=new Map,this.rc=-1,this.hc=[],this.ac=1,this.yn=t,this.Do=n,this.lc=t.rightOffset,this.oc=t.barSpacing,this.sn=e,this._c(t),this.Pu=r,this.uc(),this.Ku.Eu(t.uniformDistribution),this.cc(),this.dc()}N(){return this.yn}fc(e){ZS(this.Do,e),this.vc(),this.uc()}vr(e,t){ZS(this.yn,e),this.yn.fixLeftEdge&&this.mc(),this.yn.fixRightEdge&&this.wc(),e.barSpacing!==void 0&&this.sn.Ms(e.barSpacing),e.rightOffset!==void 0&&this.sn.gs(e.rightOffset),this._c(e),e.minBarSpacing===void 0&&e.maxBarSpacing===void 0||this.sn.Ms(e.barSpacing??this.oc),e.ignoreWhitespaceIndices!==void 0&&e.ignoreWhitespaceIndices!==this.yn.ignoreWhitespaceIndices&&this.dc(),this.vc(),this.uc(),e.enableConflation===void 0&&e.conflationThresholdFactor===void 0||this.cc(),this.tc.p()}Rn(e){return this.Yu[e]?.time??null}en(e){return this.Yu[e]??null}Mc(e,t){if(this.Yu.length<1)return null;if(this.Pu.key(e)>this.Pu.key(this.Yu[this.Yu.length-1].time))return t?this.Yu.length-1:null;let n=fw(this.Yu,this.Pu.key(e),((e,t)=>this.Pu.key(e.time)<t));return this.Pu.key(e)<this.Pu.key(this.Yu[n].time)?t?n:null:n}Zi(){return this.k_===0||this.Yu.length===0||this.qu===null}gc(){return this.Yu.length>0}Ee(){return this.bc(),this.Zu.Uu()}Sc(){return this.bc(),this.Zu.$u()}xc(){let e=this.Ee();if(e===null)return null;let t={from:e.Na(),to:e.bi()};return this.Cc(t)}Cc(e){let t=Math.round(e.from),n=Math.round(e.to),r=$(this.yc()),i=$(this.Pc());return{from:$(this.en(Math.max(r,t))),to:$(this.en(Math.min(i,n)))}}kc(e){return{from:$(this.Mc(e.from,!0)),to:$(this.Mc(e.to,!0))}}nn(){return this.k_}H_(e){if(!isFinite(e)||e<=0||this.k_===e)return;let t=this.Sc(),n=this.k_;if(this.k_=e,this.Xu=!0,this.yn.lockVisibleTimeRangeOnResize&&n!==0){let t=this.oc*e/n;this.oc=t}if(this.yn.fixLeftEdge&&t!==null&&t.Na()<=0){let t=n-e;this.lc-=Math.round(t/this.oc)+1,this.Xu=!0}this.Tc(),this.Rc()}jt(e){if(this.Zi()||!$S(e))return 0;let t=this.Dc()+this.lc-e;return this.k_-(t+.5)*this.oc-1}Ic(e,t){let n=this.Dc(),r=t===void 0?0:t.from,i=t===void 0?e.length:t.to;for(let t=r;t<i;t++){let r=e[t].wt,i=n+this.lc-r,a=this.k_-(i+.5)*this.oc-1;e[t]._t=a}}Vc(e,t){let n=Math.ceil(this.Bc(e));return t&&this.yn.ignoreWhitespaceIndices&&!this.Ec(n)?this.Ac(n):n}gs(e){this.Xu=!0,this.lc=e,this.Rc(),this.sn.Lc(),this.sn.mr()}ml(){return this.oc}Ms(e){let t=this.oc;if(this.zc(e),this.yn.rightOffsetPixels!==void 0&&t!==0){let e=this.lc*t/this.oc;this.lc=e}this.Rc(),this.sn.Lc(),this.sn.mr()}Oc(){return this.lc}zl(){if(this.Zi())return null;if(this.sc!==null)return this.sc;let e=this.oc,t=5*(this.sn.N().layout.fontSize+4)/8*(this.yn.tickMarkMaxCharacterLength||8),n=Math.round(t/e),r=$(this.Ee()),i=Math.max(r.Na(),r.Na()-n),a=Math.max(r.bi(),r.bi()-n),o=this.Ku.zu(e,t,this.yn.ignoreWhitespaceIndices,this.ec,this.rc),s=this.yc()+n,c=this.Pc()-n,l=this.Nc(),u=this.yn.fixLeftEdge||l,d=this.yn.fixRightEdge||l,f=0;for(let e of o){if(!(i<=e.index&&e.index<=a))continue;let n;f<this.hc.length?(n=this.hc[f],n.coord=this.jt(e.index),n.label=this.Fc(e),n.weight=e.weight):(n={needAlignCoordinate:!1,coord:this.jt(e.index),label:this.Fc(e),weight:e.weight},this.hc.push(n)),this.oc>t/2&&!l?n.needAlignCoordinate=!1:n.needAlignCoordinate=u&&e.index<=s||d&&e.index>=c,f++}return this.hc.length=f,this.sc=this.hc,this.hc}Wc(){let e;this.Xu=!0,this.Ms(this.yn.barSpacing),e=this.yn.rightOffsetPixels===void 0?this.yn.rightOffset:this.yn.rightOffsetPixels/this.ml(),this.gs(e)}Hc(e){this.Xu=!0,this.qu=e,this.Rc(),this.mc()}Uc(e,t){let n=this.Bc(e),r=this.ml(),i=r+r/10*t;this.Ms(i),this.yn.rightBarStaysOnScroll||this.gs(this.Oc()+(n-this.Bc(e)))}u_(e){this.Po&&this.v_(),this.yo===null&&this.nc===null&&(this.Zi()||(this.yo=e,this.$c()))}c_(e){if(this.nc===null)return;let t=zw(this.k_-e,0,this.k_),n=zw(this.k_-$(this.yo),0,this.k_);t!==0&&n!==0&&this.Ms(this.nc.ml*t/n)}d_(){this.yo!==null&&(this.yo=null,this.jc())}f_(e){this.Po===null&&this.nc===null&&(this.Zi()||(this.Po=e,this.$c()))}p_(e){if(this.Po===null)return;let t=(this.Po-e)/this.ml();this.lc=$(this.nc).Oc+t,this.Xu=!0,this.Rc()}v_(){this.Po!==null&&(this.Po=null,this.jc())}qc(){this.Yc(this.yn.rightOffset)}Yc(e,t=400){if(!isFinite(e))throw RangeError(`offset is required and must be finite number`);if(!isFinite(t)||t<=0)throw RangeError(`animationDuration (optional) must be finite positive number`);let n=this.lc,r=performance.now();this.sn.ps({Kc:e=>(e-r)/t>=1,Gc:i=>{let a=(i-r)/t;return a>=1?e:n+(e-n)*a}})}Pt(e,t){this.Xu=!0,this.Yu=e,this.Ku.Au(e,t),this.Rc()}Zc(){return this.Ju}Xc(){return this.Qu}Jc(){return this.tc}Dc(){return this.qu||0}Qc(e,t){let n=e.Iu(),r=t&&this.yn.rightOffsetPixels||0;this.zc((this.k_-r)/n),this.lc=e.bi()-this.Dc(),t&&(this.lc=r?r/this.ml():this.yn.rightOffset),this.Rc(),this.Xu=!0,this.sn.Lc(),this.sn.mr()}td(){let e=this.yc(),t=this.Pc();if(e===null||t===null)return;let n=!this.yn.rightOffsetPixels&&this.yn.rightOffset||0;this.Qc(new _T(e,t+n),!0)}nd(e){let t=new _T(e.from,e.to);this.Qc(t)}rn(e){return this.Do.timeFormatter===void 0?this.Pu.formatHorzItem(e.time):this.Do.timeFormatter(e.originalTime)}dc(){if(!this.yn.ignoreWhitespaceIndices)return;this.ec.clear();let e=this.sn.Jn();for(let t of e)for(let e of t.fl())this.ec.set(e,!0);this.rc++}sd(){return this.ac}Sl(){let e=1/(window.devicePixelRatio||1),t=this.yn.minBarSpacing;if(t>=e)return[1];let n=[1],r=2;for(;r<=512;)t<e/r&&n.push(r),r*=2;return n}Nc(){let e=this.sn.N().handleScroll,t=this.sn.N().handleScale;return!(e.horzTouchDrag||e.mouseWheel||e.pressedMouseMove||e.vertTouchDrag||t.axisDoubleClickReset.time||t.axisPressedMouseMove.time||t.mouseWheel||t.pinch)}yc(){return this.Yu.length===0?null:0}Pc(){return this.Yu.length===0?null:this.Yu.length-1}ed(e){return(this.k_-1-e)/this.oc}Bc(e){let t=this.ed(e),n=this.Dc()+this.lc-t;return Math.round(1e6*n)/1e6}zc(e){let t=this.oc;this.oc=e,this.Tc(),t!==this.oc&&(this.Xu=!0,this.rd(),this.cc())}bc(){if(!this.Xu)return;if(this.Xu=!1,this.Zi())return void this.hd(bT.ju());let e=this.Dc(),t=this.k_/this.oc,n=this.lc+e,r=new _T(n-t+1,n);this.hd(new bT(r))}Tc(){let e=zw(this.oc,this.ad(),this.ld());this.oc!==e&&(this.oc=e,this.Xu=!0)}ld(){return this.yn.maxBarSpacing>0?this.yn.maxBarSpacing:.5*this.k_}ad(){return this.yn.fixLeftEdge&&this.yn.fixRightEdge&&this.Yu.length!==0?this.k_/this.Yu.length:this.yn.minBarSpacing}cc(){if(!this.yn.enableConflation)return void(this.ac=1);let e=1/(window.devicePixelRatio||1)*(this.yn.conflationThresholdFactor??1);if(this.oc>=e)return void(this.ac=1);let t=e/this.oc,n=2**Math.floor(Math.log2(t));this.ac=Math.min(n,512)}Rc(){let e=this.od();e!==null&&this.lc<e&&(this.lc=e,this.Xu=!0);let t=this._d();this.lc>t&&(this.lc=t,this.Xu=!0)}od(){let e=this.yc(),t=this.qu;return e===null||t===null?null:e-t-1+(this.yn.fixLeftEdge?this.k_/this.oc:Math.min(2,this.Yu.length))}_d(){return this.yn.fixRightEdge?0:this.k_/this.oc-Math.min(2,this.Yu.length)}$c(){this.nc={ml:this.ml(),Oc:this.Oc()}}jc(){this.nc=null}Fc(e){let t=this.Gu.get(e.weight);return t===void 0&&(t=new gT((e=>this.ud(e)),this.Pu),this.Gu.set(e.weight,t)),t.ku(e)}ud(e){return this.Pu.formatTickmark(e,this.Do)}hd(e){let t=this.Zu;this.Zu=e,vT(t.Uu(),this.Zu.Uu())||this.Ju.p(),vT(t.$u(),this.Zu.$u())||this.Qu.p(),this.rd()}rd(){this.sc=null}vc(){this.rd(),this.Gu.clear()}uc(){this.Pu.updateFormatter(this.Do)}mc(){if(!this.yn.fixLeftEdge)return;let e=this.yc();if(e===null)return;let t=this.Ee();if(t===null)return;let n=t.Na()-e;if(n<0){let e=this.lc-n-1;this.gs(e)}this.Tc()}wc(){this.Rc(),this.Tc()}Ec(e){return!this.yn.ignoreWhitespaceIndices||this.ec.get(e)||!1}Ac(e){let t=function*(e){let t=Math.round(e),n=t<e,r=1;for(;;)n?(yield t+r,yield t-r):(yield t-r,yield t+r),r++}(e),n=this.Pc();for(;n;){let e=t.next().value;if(this.ec.get(e))return e;if(e<0||e>n)break}return e}_c(e){if(e.rightOffsetPixels!==void 0){let t=e.rightOffsetPixels/(e.barSpacing||this.oc);this.sn.gs(t)}}},CT,wT,TT,ET,DT;(function(e){e[e.OnTouchEnd=0]=`OnTouchEnd`,e[e.OnNextTap=1]=`OnNextTap`})(CT||={});var OT=class{constructor(e,t,n){this.dd=[],this.fd=[],this.pd=null,this.k_=0,this.vd=null,this.md=new XS,this.wd=new XS,this.Md=null,this.gd=e,this.yn=t,this.Pu=n,this.Io=new uC(this.yn.layout.colorParsers),this.bd=new sC(this),this.ia=new ST(this,t.timeScale,this.yn.localization,n),this.Ct=new MC(this,t.crosshair),this.Sd=new Rw(t.crosshair),t.addDefaultPane&&(this.xd(0),this.dd[0].W_(2)),this.Cd=this.yd(0),this.Pd=this.yd(1)}ka(){this.kd(PC.ys())}mr(){this.kd(PC.Cs())}Ya(){this.kd(new PC(1))}Ta(e){let t=this.Td(e);this.kd(t)}cu(){return this.vd}Rd(e){if(this.vd?.uu===e?.uu&&this.vd?.bu?.te===e?.bu?.te&&this.vd?.bu?.ie===e?.bu?.ie&&this.vd?.gu===e?.gu&&this.vd?.ee===e?.ee)return;let t=this.vd;this.vd=e,t!==null&&this.Ta(t.uu),e!==null&&e.uu!==t?.uu&&this.Ta(e.uu)}N(){return this.yn}vr(e){ZS(this.yn,e),this.dd.forEach((t=>t.z_(e))),e.timeScale!==void 0&&this.ia.vr(e.timeScale),e.localization!==void 0&&this.ia.fc(e.localization),(e.leftPriceScale||e.rightPriceScale)&&this.md.p(),this.Cd=this.yd(0),this.Pd=this.yd(1),this.ka()}Dd(e,t,n=0){let r=this.dd[n];if(r===void 0)return;if(e===`left`)return ZS(this.yn,{leftPriceScale:t}),r.z_({leftPriceScale:t}),this.md.p(),void this.ka();if(e===`right`)return ZS(this.yn,{rightPriceScale:t}),r.z_({rightPriceScale:t}),this.md.p(),void this.ka();let i=this.Id(e,n);i!==null&&(i.Ft.vr(t),this.md.p())}Id(e,t){let n=this.dd[t];if(n===void 0)return null;let r=n.O_(e);return r===null?null:{Kn:n,Ft:r}}Et(){return this.ia}Gn(){return this.dd}Vd(){return this.Ct}Bd(){return this.wd}Ed(e,t){e.$o(t),this.Lc()}H_(e){this.k_=e,this.ia.H_(this.k_),this.dd.forEach((t=>t.H_(e))),this.Lc()}Ad(e){this.dd.length!==1&&(qS(e>=0&&e<this.dd.length,`Invalid pane index`),this.dd.splice(e,1),this.ka())}Ld(e,t){if(this.dd.length<2)return;qS(e>=0&&e<this.dd.length,`Invalid pane index`);let n=this.dd[e],r=this.dd.reduce(((e,t)=>e+t.F_()),0),i=this.dd.reduce(((e,t)=>e+t.$t()),0),a=i-30*(this.dd.length-1);t=Math.min(a,Math.max(30,t));let o=r/i,s=n.$t();n.W_(t*o);let c=t-s,l=this.dd.length-1;for(let e of this.dd)if(e!==n){let t=Math.min(a,Math.max(30,e.$t()-c/l));c-=e.$t()-t,--l;let n=t*o;e.W_(n)}this.ka()}zd(e,t){qS(e>=0&&e<this.dd.length&&t>=0&&t<this.dd.length,`Invalid pane index`);let n=this.dd[e],r=this.dd[t];this.dd[e]=r,this.dd[t]=n,this.ka()}Od(e,t){if(qS(e>=0&&e<this.dd.length&&t>=0&&t<this.dd.length,`Invalid pane index`),e===t)return;let[n]=this.dd.splice(e,1);this.dd.splice(t,0,n),this.ka()}Q_(e,t,n){e.Q_(t,n)}tu(e,t,n){e.tu(t,n),this.Ra(),this.kd(this.Nd(e,2))}iu(e,t){e.iu(t),this.kd(this.Nd(e,2))}nu(e,t,n){t.zo()||e.nu(t,n)}su(e,t,n){t.zo()||(e.su(t,n),this.Ra(),this.kd(this.Nd(e,2)))}eu(e,t){t.zo()||(e.eu(t),this.kd(this.Nd(e,2)))}au(e,t){e.au(t),this.kd(this.Nd(e,2))}Fd(e){this.ia.u_(e)}Wd(e,t){let n=this.Et();if(n.Zi()||t===0)return;let r=n.nn();e=Math.max(1,Math.min(e,r)),n.Uc(e,t),this.Lc()}Hd(e){this.Ud(0),this.$d(e),this.jd()}qd(e){this.ia.c_(e),this.Lc()}Yd(){this.ia.d_(),this.mr()}Ud(e){this.ia.f_(e)}$d(e){this.ia.p_(e),this.Lc()}jd(){this.ia.v_(),this.mr()}Jn(){return this.fd}Wn(){return this.pd===null&&(this.pd=this.fd.filter((e=>e.It()))),this.pd}Pa(){this.pd=null}Kd(e,t,n,r,i){this.Ct.In(e,t);let a=NaN,o=this.ia.Vc(e,!0),s=this.ia.Ee();s!==null&&(o=Math.min(Math.max(s.Na(),o),s.bi())),o=this.Ct.Fn(o);let c=r.kn(),l=c.Lt();if(l!==null&&(a=c.Tn(t,l)),a=this.Sd.Pl(a,o,r),this.Ct.An(o,a,r),this.Ya(),!i){let i=hT(r,e,t);this.Rd(i&&{uu:i.uu,bu:i.bu,gu:i.gu||null,ee:i.ee}),this.wd.p(this.Ct.Bt(),{x:e,y:t},n)}}Gd(e,t,n){let r=n.kn(),i=r.Lt(),a=r.Nt(e,$(i)),o=this.ia.Mc(t,!0),s=this.ia.jt($(o));this.Kd(s,a,null,n,!0)}Zd(e){this.Vd().zn(),this.Ya(),e||this.wd.p(null,null,null)}Ra(){let e=this.Ct.Kn();if(e!==null){let t=this.Ct.Bn(),n=this.Ct.En();this.Kd(t,n,null,e)}this.Ct.Nn()}Xd(e,t,n){let r=this.ia.Rn(0);t!==void 0&&n!==void 0&&this.ia.Pt(t,n);let i=this.ia.Rn(0),a=this.ia.Dc(),o=this.ia.Ee();if(o!==null&&r!==null&&i!==null){let t=o.ze(a),s=this.Pu.key(r)>this.Pu.key(i),c=e!==null&&e>a&&!s,l=this.ia.N().allowShiftVisibleRangeOnWhitespaceReplacement,u=t&&(n!==void 0||l)&&this.ia.N().shiftVisibleRangeOnNewBar;if(c&&!u){let t=e-a;this.ia.gs(this.ia.Oc()-t)}}this.ia.Hc(e)}Ba(e){e!==null&&e.ou()}Ks(e){if(function(e){return e instanceof cT}(e))return e;let t=this.dd.find((t=>t.Dt().includes(e)));return t===void 0?null:t}Lc(){this.dd.forEach((e=>e.ou())),this.Ra()}m(){this.dd.forEach((e=>e.m())),this.dd.length=0,this.yn.localization.priceFormatter=void 0,this.yn.localization.percentageFormatter=void 0,this.yn.localization.timeFormatter=void 0}Jd(){return this.bd}Js(){return this.bd.N()}N_(){return this.md}Qd(e,t){let n=this.xd(t);this.tf(e,n),this.fd.push(e),this.Pa(),this.fd.length===1?this.ka():this.mr()}if(e){let t=this.Ks(e),n=this.fd.indexOf(e);qS(n!==-1,`Series not found`);let r=$(t);this.fd.splice(n,1),r.l_(e),e.m&&e.m(),this.Pa(),this.ia.dc(),this.nf(r)}ya(e,t){let n=$(this.Ks(e));n.l_(e,!0),n.h_(e,t,!0)}td(){let e=PC.Cs();e.us(),this.kd(e)}sf(e){let t=PC.Cs();t.fs(e),this.kd(t)}ws(){let e=PC.Cs();e.ws(),this.kd(e)}Ms(e){let t=PC.Cs();t.Ms(e),this.kd(t)}gs(e){let t=PC.Cs();t.gs(e),this.kd(t)}ps(e){let t=PC.Cs();t.ps(e),this.kd(t)}cs(){let e=PC.Cs();e.cs(),this.kd(e)}ef(){let e=this.yn.defaultVisiblePriceScaleId,t=this.yn.leftPriceScale.visible;return t===this.yn.rightPriceScale.visible?e:t?`left`:`right`}rf(e,t){if(qS(t>=0,`Index should be greater or equal to 0`),t===this.hf(e))return;let n=$(this.Ks(e));n.l_(e);let r=this.xd(t);this.tf(e,r);let i=!1;n.kl().length===0&&(i=this.nf(n)),i||this.ka()}af(){return this.Pd}$(){return this.Cd}Ut(e){let t=this.Pd,n=this.Cd;if(t===n)return t;if(e=Math.max(0,Math.min(100,Math.round(100*e))),this.Md===null||this.Md.ah!==n||this.Md.oh!==t)this.Md={ah:n,oh:t,lf:new Map};else{let t=this.Md.lf.get(e);if(t!==void 0)return t}let r=this.Io.tt(n,t,e/100);return this.Md.lf.set(e,r),r}_f(e){return this.dd.indexOf(e)}Xi(){return this.Io}uf(){return this.cf()}cf(e){let t=new cT(this.ia,this);this.dd.push(t);let n=e??this.dd.length-1,r=PC.ys();return r.es(n,{rs:0,hs:!0}),this.kd(r),t}xd(e){return qS(e>=0,`Index should be greater or equal to 0`),(e=Math.min(this.dd.length,e))<this.dd.length?this.dd[e]:this.cf(e)}hf(e){return this.dd.findIndex((t=>t.Y_().includes(e)))}Nd(e,t){let n=new PC(t);if(e!==null){let r=this.dd.indexOf(e);n.es(r,{rs:t})}return n}Td(e,t){return t===void 0&&(t=2),this.Nd(this.Ks(e),t)}kd(e){this.gd&&this.gd(e),this.dd.forEach((e=>e.wu().wr().Pt()))}tf(e,t){let n=e.N().priceScaleId,r=n===void 0?this.ef():n;t.h_(e,r),NC(r)||e.vr(e.N())}yd(e){let t=this.yn.layout;return t.background.type===`gradient`?e===0?t.background.topColor:t.background.bottomColor:t.background.color}nf(e){return!e.q_()&&e.kl().length===0&&this.dd.length>1&&(this.dd.splice(this._f(e),1),this.ka(),!0)}};function kT(e){if(e>=1)return 0;let t=0;for(;t<8;t++){if(Math.abs(Math.round(e)-e)<1e-8)return t;e*=10}return t}function AT(e){return!QS(e)&&!eC(e)}function jT(e){return QS(e)}(function(e){e[e.Disabled=0]=`Disabled`,e[e.Continuous=1]=`Continuous`,e[e.OnDataUpdate=2]=`OnDataUpdate`})(wT||={}),function(e){e[e.LastBar=0]=`LastBar`,e[e.LastVisible=1]=`LastVisible`}(TT||={}),function(e){e.Solid=`solid`,e.VerticalGradient=`gradient`}(ET||={}),function(e){e[e.Year=0]=`Year`,e[e.Month=1]=`Month`,e[e.DayOfMonth=2]=`DayOfMonth`,e[e.Time=3]=`Time`,e[e.TimeWithSeconds=4]=`TimeWithSeconds`}(DT||={});var MT=e=>e.getUTCFullYear();function NT(e,t,n){return t.replace(/yyyy/g,(e=>LC(MT(e),4))(e)).replace(/yy/g,(e=>LC(MT(e)%100,2))(e)).replace(/MMMM/g,((e,t)=>new Date(e.getUTCFullYear(),e.getUTCMonth(),1).toLocaleString(t,{month:`long`}))(e,n)).replace(/MMM/g,((e,t)=>new Date(e.getUTCFullYear(),e.getUTCMonth(),1).toLocaleString(t,{month:`short`}))(e,n)).replace(/MM/g,(e=>LC((e=>e.getUTCMonth()+1)(e),2))(e)).replace(/dd/g,(e=>LC((e=>e.getUTCDate())(e),2))(e))}var PT=class{constructor(e=`yyyy-MM-dd`,t=`default`){this.df=e,this.ff=t}ku(e){return NT(e,this.df,this.ff)}},FT=class{constructor(e){this.pf=e||`%h:%m:%s`}ku(e){return this.pf.replace(`%h`,LC(e.getUTCHours(),2)).replace(`%m`,LC(e.getUTCMinutes(),2)).replace(`%s`,LC(e.getUTCSeconds(),2))}},IT={vf:`yyyy-MM-dd`,mf:`%h:%m:%s`,wf:` `,Mf:`default`},LT=class{constructor(e={}){let t={...IT,...e};this.gf=new PT(t.vf,t.Mf),this.bf=new FT(t.mf),this.Sf=t.wf}ku(e){return`${this.gf.ku(e)}${this.Sf}${this.bf.ku(e)}`}};function RT(e){return 60*e*60*1e3}function zT(e){return 60*e*1e3}var BT=[{xf:(VT=1,1e3*VT),Cf:10},{xf:zT(1),Cf:20},{xf:zT(5),Cf:21},{xf:zT(30),Cf:22},{xf:RT(1),Cf:30},{xf:RT(3),Cf:31},{xf:RT(6),Cf:32},{xf:RT(12),Cf:33}],VT;function HT(e,t){if(e.getUTCFullYear()!==t.getUTCFullYear())return 70;if(e.getUTCMonth()!==t.getUTCMonth())return 60;if(e.getUTCDate()!==t.getUTCDate())return 50;for(let n=BT.length-1;n>=0;--n)if(Math.floor(t.getTime()/BT[n].xf)!==Math.floor(e.getTime()/BT[n].xf))return BT[n].Cf;return 0}function UT(e){let t=e;if(eC(e)&&(t=GT(e)),!AT(t))throw Error(`time must be of type BusinessDay`);let n=new Date(Date.UTC(t.year,t.month-1,t.day,0,0,0,0));return{yf:Math.round(n.getTime()/1e3),Pf:t}}function WT(e){if(!jT(e))throw Error(`time must be of type isUTCTimestamp`);return{yf:e}}function GT(e){let t=new Date(e);if(isNaN(t.getTime()))throw Error(`Invalid date string=${e}, expected format=yyyy-mm-dd`);return{day:t.getUTCDate(),month:t.getUTCMonth()+1,year:t.getUTCFullYear()}}function KT(e){eC(e.time)&&(e.time=GT(e.time))}var qT=class{options(){return this.yn}setOptions(e){this.yn=e,this.updateFormatter(e.localization)}preprocessData(e){Array.isArray(e)?function(e){e.forEach(KT)}(e):KT(e)}createConverterToInternalObj(e){return $(function(e){return e.length===0?null:AT(e[0].time)||eC(e[0].time)?UT:WT}(e))}key(e){return typeof e==`object`&&`yf`in e?e.yf:this.key(this.convertHorzItemToInternal(e))}cacheKey(e){let t=e;return t.Pf===void 0?new Date(1e3*t.yf).getTime():new Date(Date.UTC(t.Pf.year,t.Pf.month-1,t.Pf.day)).getTime()}convertHorzItemToInternal(e){return jT(t=e)?WT(t):AT(t)?UT(t):UT(GT(t));var t}updateFormatter(e){if(!this.yn)return;let t=e.dateFormat;this.kf=this.yn.timeScale.timeVisible?new LT({vf:t,mf:this.yn.timeScale.secondsVisible?`%h:%m:%s`:`%h:%m`,wf:` `,Mf:e.locale}):new PT(t,e.locale)}formatHorzItem(e){let t=e;return this.kf.ku(new Date(1e3*t.yf))}formatTickmark(e,t){let n=function(e,t,n){switch(e){case 0:case 10:return t?n?4:3:2;case 20:case 21:case 22:case 30:case 31:case 32:case 33:return t?3:2;case 50:return 2;case 60:return 1;case 70:return 0}}(e.weight,this.yn.timeScale.timeVisible,this.yn.timeScale.secondsVisible),r=this.yn.timeScale;if(r.tickMarkFormatter!==void 0){let i=r.tickMarkFormatter(e.originalTime,n,t.locale);if(i!==null)return i}return function(e,t,n){let r={};switch(t){case 0:r.year=`numeric`;break;case 1:r.month=`short`;break;case 2:r.day=`numeric`;break;case 3:r.hour12=!1,r.hour=`2-digit`,r.minute=`2-digit`;break;case 4:r.hour12=!1,r.hour=`2-digit`,r.minute=`2-digit`,r.second=`2-digit`}let i=e.Pf===void 0?new Date(1e3*e.yf):new Date(Date.UTC(e.Pf.year,e.Pf.month-1,e.Pf.day));return new Date(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate(),i.getUTCHours(),i.getUTCMinutes(),i.getUTCSeconds(),i.getUTCMilliseconds()).toLocaleString(n,r)}(e.time,n,t.locale)}maxTickMarkWeight(e){let t=e.reduce(xT,e[0]).weight;return t>30&&t<50&&(t=30),t}fillWeightsForPoints(e,t){(function(e,t=0){if(e.length===0)return;let n=t===0?null:e[t-1].time.yf,r=n===null?null:new Date(1e3*n),i=0;for(let a=t;a<e.length;++a){let t=e[a],o=new Date(1e3*t.time.yf);r!==null&&(t.timeWeight=HT(o,r)),i+=t.time.yf-(n||t.time.yf),n=t.time.yf,r=o}if(t===0&&e.length>1){let t=Math.ceil(i/(e.length-1)),n=new Date(1e3*(e[0].time.yf-t));e[0].timeWeight=HT(new Date(1e3*e[0].time.yf),n)}})(e,t)}static Tf(e){return ZS({localization:{dateFormat:`dd MMM 'yy`}},e??{})}},JT=typeof window<`u`;function YT(){return!!JT&&window.navigator.userAgent.toLowerCase().indexOf(`firefox`)>-1}function XT(){return!!JT&&/iPhone|iPad|iPod/.test(window.navigator.platform)}function ZT(e,t){switch(e){case`custom`:return t===void 0?`series`:`custom-object`;case`price-line`:return`custom-price-line`;case`marker`:return`series-marker`;case`primitive`:return`primitive`;default:return`series`}}function QT(e){return e+e%2}function $T(e){JT&&window.chrome!==void 0&&e.addEventListener(`mousedown`,(e=>{if(e.button===1)return e.preventDefault(),!1}))}var eE=class{constructor(e,t,n){this.Rf=0,this.Df=null,this.If={_t:-1/0,ut:1/0},this.Vf=0,this.Bf=null,this.Ef={_t:-1/0,ut:1/0},this.Af=null,this.Lf=!1,this.zf=null,this.Of=null,this.Nf=!1,this.Ff=!1,this.Wf=!1,this.Hf=null,this.Uf=null,this.$f=null,this.jf=null,this.qf=null,this.Yf=null,this.Kf=null,this.Gf=0,this.Zf=!1,this.Xf=!1,this.Jf=!1,this.Qf=0,this.tp=null,this.ip=!XT(),this.np=e=>{this.sp(e)},this.ep=e=>{if(this.rp(e)){let t=this.hp(e);if(++this.Vf,this.Bf&&this.Vf>1){let{ap:n}=this.lp(rE(e),this.Ef);n<30&&!this.Wf&&this.op(t,this.up._p),this.cp()}}else{let t=this.hp(e);if(++this.Rf,this.Df&&this.Rf>1){let{ap:n}=this.lp(rE(e),this.If);n<5&&!this.Ff&&this.dp(t,this.up.fp),this.pp()}}},this.vp=e,this.up=t,this.yn=n,this.mp()}m(){this.Hf!==null&&(this.Hf(),this.Hf=null),this.Uf!==null&&(this.Uf(),this.Uf=null),this.jf!==null&&(this.jf(),this.jf=null),this.qf!==null&&(this.qf(),this.qf=null),this.Yf!==null&&(this.Yf(),this.Yf=null),this.$f!==null&&(this.$f(),this.$f=null),this.wp(),this.pp()}Mp(e){this.jf&&this.jf();let t=this.gp.bind(this);if(this.jf=()=>{this.vp.removeEventListener(`mousemove`,t)},this.vp.addEventListener(`mousemove`,t),this.rp(e))return;let n=this.hp(e);this.dp(n,this.up.bp),this.ip=!0}pp(){this.Df!==null&&clearTimeout(this.Df),this.Rf=0,this.Df=null,this.If={_t:-1/0,ut:1/0}}cp(){this.Bf!==null&&clearTimeout(this.Bf),this.Vf=0,this.Bf=null,this.Ef={_t:-1/0,ut:1/0}}gp(e){if(this.Jf||this.Of!==null||this.rp(e))return;let t=this.hp(e);this.dp(t,this.up.Sp),this.ip=!0}xp(e){let t=aE(e.changedTouches,$(this.tp));if(t===null||(this.Qf=iE(e),this.Kf!==null)||this.Xf)return;this.Zf=!0;let{Cp:n,yp:r,ap:i}=this.lp(rE(t),$(this.Of));if(this.Nf||!(i<5)){if(!this.Nf){let e=.5*n,t=r>=e&&!this.yn.Pp(),i=e>r&&!this.yn.kp();t||i||(this.Xf=!0),this.Nf=!0,this.Wf=!0,this.wp(),this.cp()}if(!this.Xf){let n=this.hp(e,t);this.op(n,this.up.Tp),nE(e)}}}Rp(e){if(e.button!==0)return;let{ap:t}=this.lp(rE(e),$(this.zf));if(t>=5&&(this.Ff=!0,this.pp()),this.Ff){let t=this.hp(e);this.dp(t,this.up.Dp)}}lp(e,t){let n=Math.abs(t._t-e._t),r=Math.abs(t.ut-e.ut);return{Cp:n,yp:r,ap:n+r}}Ip(e){let t=aE(e.changedTouches,$(this.tp));if(t===null&&e.touches.length===0&&(t=e.changedTouches[0]),t===null)return;this.tp=null,this.Qf=iE(e),this.wp(),this.Of=null,this.Yf&&=(this.Yf(),null);let n=this.hp(e,t);if(this.op(n,this.up.Vp),++this.Vf,this.Bf&&this.Vf>1){let{ap:e}=this.lp(rE(t),this.Ef);e<30&&!this.Wf&&this.op(n,this.up._p),this.cp()}else this.Wf||(this.op(n,this.up.Bp),this.up.Bp&&nE(e));this.Vf===0&&nE(e),e.touches.length===0&&this.Lf&&(this.Lf=!1,nE(e))}sp(e){if(e.button!==0)return;let t=this.hp(e);if(this.zf=null,this.Jf=!1,this.qf&&=(this.qf(),null),YT()&&this.vp.ownerDocument.documentElement.removeEventListener(`mouseleave`,this.np),!this.rp(e)){if(this.dp(t,this.up.Ep),++this.Rf,this.Df&&this.Rf>1){let{ap:n}=this.lp(rE(e),this.If);n<5&&!this.Ff&&this.dp(t,this.up.fp),this.pp()}else this.Ff||this.dp(t,this.up.Ap)}}wp(){this.Af!==null&&(clearTimeout(this.Af),this.Af=null)}Lp(e){if(this.tp!==null)return;let t=e.changedTouches[0];this.tp=t.identifier,this.Qf=iE(e);let n=this.vp.ownerDocument.documentElement;this.Wf=!1,this.Nf=!1,this.Xf=!1,this.Of=rE(t),this.Yf&&=(this.Yf(),null);{let t=this.xp.bind(this),r=this.Ip.bind(this);this.Yf=()=>{n.removeEventListener(`touchmove`,t),n.removeEventListener(`touchend`,r)},n.addEventListener(`touchmove`,t,{passive:!1}),n.addEventListener(`touchend`,r,{passive:!1}),this.wp(),this.Af=setTimeout(this.zp.bind(this,e),240)}let r=this.hp(e,t);this.op(r,this.up.Op),this.Bf||(this.Vf=0,this.Bf=setTimeout(this.cp.bind(this),500),this.Ef=rE(t))}Np(e){if(e.button!==0)return;let t=this.vp.ownerDocument.documentElement;YT()&&t.addEventListener(`mouseleave`,this.np),this.Ff=!1,this.zf=rE(e),this.qf&&=(this.qf(),null);{let e=this.Rp.bind(this),n=this.sp.bind(this);this.qf=()=>{t.removeEventListener(`mousemove`,e),t.removeEventListener(`mouseup`,n)},t.addEventListener(`mousemove`,e),t.addEventListener(`mouseup`,n)}if(this.Jf=!0,this.rp(e))return;let n=this.hp(e);this.dp(n,this.up.Fp),this.Df||(this.Rf=0,this.Df=setTimeout(this.pp.bind(this),500),this.If=rE(e))}mp(){this.vp.addEventListener(`mouseenter`,this.Mp.bind(this)),this.vp.addEventListener(`touchcancel`,this.wp.bind(this));{let e=this.vp.ownerDocument,t=e=>{this.up.Wp&&(e.composed&&this.vp.contains(e.composedPath()[0])||e.target&&this.vp.contains(e.target)||this.up.Wp())};this.Uf=()=>{e.removeEventListener(`touchstart`,t)},this.Hf=()=>{e.removeEventListener(`mousedown`,t)},e.addEventListener(`mousedown`,t),e.addEventListener(`touchstart`,t,{passive:!0})}XT()&&(this.$f=()=>{this.vp.removeEventListener(`dblclick`,this.ep)},this.vp.addEventListener(`dblclick`,this.ep)),this.vp.addEventListener(`mouseleave`,this.Hp.bind(this)),this.vp.addEventListener(`touchstart`,this.Lp.bind(this),{passive:!0}),$T(this.vp),this.vp.addEventListener(`mousedown`,this.Np.bind(this)),this.Up(),this.vp.addEventListener(`touchmove`,(()=>{}),{passive:!1})}Up(){this.up.$p===void 0&&this.up.jp===void 0&&this.up.qp===void 0||(this.vp.addEventListener(`touchstart`,(e=>this.Yp(e.touches)),{passive:!0}),this.vp.addEventListener(`touchmove`,(e=>{if(e.touches.length===2&&this.Kf!==null&&this.up.jp!==void 0){let t=tE(e.touches[0],e.touches[1])/this.Gf;this.up.jp(this.Kf,t),nE(e)}}),{passive:!1}),this.vp.addEventListener(`touchend`,(e=>{this.Yp(e.touches)})))}Yp(e){e.length===1&&(this.Zf=!1),e.length!==2||this.Zf||this.Lf?this.Kp():this.Gp(e)}Gp(e){let t=this.vp.getBoundingClientRect()||{left:0,top:0};this.Kf={_t:(e[0].clientX-t.left+(e[1].clientX-t.left))/2,ut:(e[0].clientY-t.top+(e[1].clientY-t.top))/2},this.Gf=tE(e[0],e[1]),this.up.$p!==void 0&&this.up.$p(),this.wp()}Kp(){this.Kf!==null&&(this.Kf=null,this.up.qp!==void 0&&this.up.qp())}Hp(e){if(this.jf&&this.jf(),this.rp(e)||!this.ip)return;let t=this.hp(e);this.dp(t,this.up.Zp),this.ip=!XT()}zp(e){let t=aE(e.touches,$(this.tp));if(t===null)return;let n=this.hp(e,t);this.op(n,this.up.Xp),this.Wf=!0,this.Lf=!0}rp(e){return e.sourceCapabilities&&e.sourceCapabilities.firesTouchEvents!==void 0?e.sourceCapabilities.firesTouchEvents:iE(e)<this.Qf+500}op(e,t){t&&t.call(this.up,e)}dp(e,t){t&&t.call(this.up,e)}hp(e,t){let n=t||e,r=this.vp.getBoundingClientRect()||{left:0,top:0};return{clientX:n.clientX,clientY:n.clientY,pageX:n.pageX,pageY:n.pageY,screenX:n.screenX,screenY:n.screenY,localX:n.clientX-r.left,localY:n.clientY-r.top,ctrlKey:e.ctrlKey,altKey:e.altKey,shiftKey:e.shiftKey,metaKey:e.metaKey,Jp:!e.type.startsWith(`mouse`)&&e.type!==`contextmenu`&&e.type!==`click`,Qp:e.type,tv:n.target,xu:e.view,iv:()=>{e.type!==`touchstart`&&nE(e)}}}};function tE(e,t){let n=e.clientX-t.clientX,r=e.clientY-t.clientY;return Math.sqrt(n*n+r*r)}function nE(e){e.cancelable&&e.preventDefault()}function rE(e){return{_t:e.pageX,ut:e.pageY}}function iE(e){return e.timeStamp||performance.now()}function aE(e,t){for(let n=0;n<e.length;++n)if(e[n].identifier===t)return e[n];return null}var oE=class{constructor(e,t,n){this.nv=null,this.sv=null,this.ev=!0,this.rv=null,this.hv=e,this.av=e.lv()[t],this.ov=e.lv()[n],this._v=document.createElement(`tr`),this._v.style.height=`1px`,this.uv=document.createElement(`td`),this.uv.style.position=`relative`,this.uv.style.padding=`0`,this.uv.style.margin=`0`,this.uv.setAttribute(`colspan`,`3`),this.cv(),this._v.appendChild(this.uv),this.ev=this.hv.N().layout.panes.enableResize,this.ev?this.dv():(this.nv=null,this.sv=null)}m(){this.sv!==null&&this.sv.m()}fv(){return this._v}pv(){return Q({width:this.av.pv().width,height:1})}vv(){return Q({width:this.av.vv().width,height:1*window.devicePixelRatio})}mv(e,t,n){let r=this.vv();e.fillStyle=this.hv.N().layout.panes.separatorColor,e.fillRect(t,n,r.width,r.height)}Pt(){this.cv(),this.hv.N().layout.panes.enableResize!==this.ev&&(this.ev=this.hv.N().layout.panes.enableResize,this.ev?this.dv():(this.nv!==null&&(this.uv.removeChild(this.nv.wv),this.uv.removeChild(this.nv.Mv),this.nv=null),this.sv!==null&&(this.sv.m(),this.sv=null)))}dv(){let e=document.createElement(`div`),t=e.style;t.position=`fixed`,t.display=`none`,t.zIndex=`49`,t.top=`0`,t.left=`0`,t.width=`100%`,t.height=`100%`,t.cursor=`row-resize`,this.uv.appendChild(e);let n=document.createElement(`div`),r=n.style;r.position=`absolute`,r.zIndex=`50`,r.top=`-4px`,r.height=`9px`,r.width=`100%`,r.backgroundColor=``,r.cursor=`row-resize`,this.uv.appendChild(n);let i={bp:this.gv.bind(this),Zp:this.bv.bind(this),Fp:this.Sv.bind(this),Op:this.Sv.bind(this),Dp:this.xv.bind(this),Tp:this.xv.bind(this),Ep:this.Cv.bind(this),Vp:this.Cv.bind(this)};this.sv=new eE(n,i,{Pp:()=>!1,kp:()=>!0}),this.nv={Mv:n,wv:e}}cv(){this.uv.style.background=this.hv.N().layout.panes.separatorColor}gv(e){this.nv!==null&&(this.nv.Mv.style.backgroundColor=this.hv.N().layout.panes.separatorHoverColor)}bv(e){this.nv!==null&&this.rv===null&&(this.nv.Mv.style.backgroundColor=``)}Sv(e){if(this.nv===null)return;let t=this.av.yv().F_()+this.ov.yv().F_(),n=t/(this.av.pv().height+this.ov.pv().height),r=30*n;t<=2*r||(this.rv={Pv:e.pageY,kv:this.av.yv().F_(),Tv:t-r,Rv:t,Dv:n,Iv:r},this.nv.wv.style.display=`block`)}xv(e){let t=this.rv;if(t===null)return;let n=(e.pageY-t.Pv)*t.Dv,r=zw(t.kv+n,t.Iv,t.Tv);this.av.yv().W_(r),this.ov.yv().W_(t.Rv-r),this.hv.Qt().ka()}Cv(e){this.rv!==null&&this.nv!==null&&(this.rv=null,this.nv.wv.style.display=`none`)}};function sE(e,t){return e.Vv-t.Vv}function cE(e,t,n){let r=(e.Vv-t.Vv)/(e.wt-t.wt);return Math.sign(r)*Math.min(Math.abs(r),n)}var lE=class{constructor(e,t,n,r){this.Bv=null,this.Ev=null,this.Av=null,this.Lv=null,this.zv=null,this.Ov=0,this.Nv=0,this.Fv=e,this.Wv=t,this.Hv=n,this.Ps=r}Uv(e,t){if(this.Bv!==null){if(this.Bv.wt===t)return void(this.Bv.Vv=e);if(Math.abs(this.Bv.Vv-e)<this.Ps)return}this.Lv=this.Av,this.Av=this.Ev,this.Ev=this.Bv,this.Bv={wt:t,Vv:e}}me(e,t){if(this.Bv===null||this.Ev===null||t-this.Bv.wt>50)return;let n=0,r=cE(this.Bv,this.Ev,this.Wv),i=sE(this.Bv,this.Ev),a=[r],o=[i];if(n+=i,this.Av!==null){let e=cE(this.Ev,this.Av,this.Wv);if(Math.sign(e)===Math.sign(r)){let t=sE(this.Ev,this.Av);if(a.push(e),o.push(t),n+=t,this.Lv!==null){let e=cE(this.Av,this.Lv,this.Wv);if(Math.sign(e)===Math.sign(r)){let t=sE(this.Av,this.Lv);a.push(e),o.push(t),n+=t}}}}let s=0;for(let e=0;e<a.length;++e)s+=o[e]/n*a[e];Math.abs(s)<this.Fv||(this.zv={Vv:e,wt:t},this.Nv=s,this.Ov=function(e,t){let n=Math.log(t);return Math.log(1*n/-e)/n}(Math.abs(s),this.Hv))}Gc(e){let t=$(this.zv),n=e-t.wt;return t.Vv+this.Nv*(this.Hv**+n-1)/Math.log(this.Hv)}Kc(e){return this.zv===null||this.$v(e)===this.Ov}$v(e){let t=e-$(this.zv).wt;return Math.min(t,this.Ov)}},uE=class{constructor(e,t){this.jv=void 0,this.qv=void 0,this.Yv=void 0,this.vn=!1,this.Kv=e,this.Gv=t,this.Zv()}Pt(){this.Zv()}Xv(){this.jv&&this.Kv.removeChild(this.jv),this.qv&&this.Kv.removeChild(this.qv),this.jv=void 0,this.qv=void 0}Jv(){return this.vn!==this.Qv()||this.Yv!==this.tm()}tm(){return this.Gv.Qt().Xi().J(this.Gv.N().layout.textColor)>160?`dark`:`light`}Qv(){return this.Gv.N().layout.attributionLogo}im(){let e=new URL(location.href);return e.hostname?`&utm_source=`+e.hostname+e.pathname:``}Zv(){this.Jv()&&(this.Xv(),this.vn=this.Qv(),this.vn&&(this.Yv=this.tm(),this.qv=document.createElement(`style`),this.qv.innerText=`a#tv-attr-logo{--fill:#131722;--stroke:#fff;position:absolute;left:10px;bottom:10px;height:19px;width:35px;margin:0;padding:0;border:0;z-index:3;}a#tv-attr-logo[data-dark]{--fill:#D1D4DC;--stroke:#131722;}`,this.jv=document.createElement(`a`),this.jv.href=`https://www.tradingview.com/?utm_medium=lwc-link&utm_campaign=lwc-chart${this.im()}`,this.jv.title=`Charting by TradingView`,this.jv.id=`tv-attr-logo`,this.jv.target=`_blank`,this.jv.innerHTML=`<svg xmlns="http://www.w3.org/2000/svg" width="35" height="19" fill="none"><g fill-rule="evenodd" clip-path="url(#a)" clip-rule="evenodd"><path fill="var(--stroke)" d="M2 0H0v10h6v9h21.4l.5-1.3 6-15 1-2.7H23.7l-.5 1.3-.2.6a5 5 0 0 0-7-.9V0H2Zm20 17h4l5.2-13 .8-2h-7l-1 2.5-.2.5-1.5 3.8-.3.7V17Zm-.8-10a3 3 0 0 0 .7-2.7A3 3 0 1 0 16.8 7h4.4ZM14 7V2H2v6h6v9h4V7h2Z"/><path fill="var(--fill)" d="M14 2H2v6h6v9h6V2Zm12 15h-7l6-15h7l-6 15Zm-7-9a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z"/></g><defs><clipPath id="a"><path fill="var(--stroke)" d="M0 0h35v19H0z"/></clipPath></defs></svg>`,this.jv.toggleAttribute(`data-dark`,this.Yv===`dark`),this.Kv.appendChild(this.qv),this.Kv.appendChild(this.jv)))}};function dE(e,t){let n=$(e.ownerDocument).createElement(`canvas`);e.appendChild(n);let r=IS(n,{type:`device-pixel-content-box`,options:{allowResizeObserver:!0},transform:(e,t)=>({width:Math.max(e.width,t.width),height:Math.max(e.height,t.height)})});return r.resizeCanvasElement(t),r}function fE(e){e.width=1,e.height=1,e.getContext(`2d`)?.clearRect(0,0,1,1)}function pE(e,t,n,r){e.qh&&e.qh(t,n,r)}function mE(e,t,n,r){e.st(t,n,r)}function hE(e,t,n,r){gE(e(n,r),t,r)}function gE(e,t,n){for(let r of e){let e=r.Tt(n);e!==null&&t(e)}}function _E(e,t){return n=>function(e){return e.Ft!==void 0}(n)&&(n.Ft()?.pl()??``)===t?n.Qa?.(e)??[]:[]}function vE(e,t,n,r){if(!e.length)return;let i=0,a=e[0].$t(r,!0),o=t===1?n/2-(e[0].Hi()-a/2):e[0].Hi()-a/2-n/2;o=Math.max(0,o);for(let a=1;a<e.length;a++){let s=e[a],c=e[a-1],l=c.$t(r,!1),u=s.Hi(),d=c.Hi();if(t===1?u>d-l:u<d+l){let r=d-l*t;s.Ui(r);let a=r-t*l/2;if((t===1?a<0:a>n)&&o>0){let r=t===1?-1-a:a-n,s=Math.min(r,o);for(let n=i;n<e.length;n++)e[n].Ui(e[n].Hi()+t*s);o-=s}}else i=a,o=t===1?d-l-u:u-(d+l)}}var yE=class{constructor(e,t,n,r){this.Ki=null,this.nm=null,this.sm=!1,this.rm=new HC(200),this.hm=null,this.am=0,this.lm=!1,this.om=()=>{this.lm||this.yt._m().Qt().mr()},this.um=()=>{this.lm||this.yt._m().Qt().mr()},this.yt=e,this.yn=t,this.Ro=t.layout,this.bd=n,this.dm=r===`left`,this.fm=_E(`normal`,r),this.pm=_E(`top`,r),this.vm=_E(`bottom`,r),this.uv=document.createElement(`div`),this.uv.style.height=`100%`,this.uv.style.overflow=`hidden`,this.uv.style.width=`25px`,this.uv.style.left=`0`,this.uv.style.position=`relative`,this.wm=dE(this.uv,Q({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om);let i=this.wm.canvasElement;i.style.position=`absolute`,i.style.zIndex=`1`,i.style.left=`0`,i.style.top=`0`,this.Mm=dE(this.uv,Q({width:16,height:16})),this.Mm.subscribeSuggestedBitmapSizeChanged(this.um);let a=this.Mm.canvasElement;a.style.position=`absolute`,a.style.zIndex=`2`,a.style.left=`0`,a.style.top=`0`;let o={Fp:this.Sv.bind(this),Op:this.Sv.bind(this),Dp:this.xv.bind(this),Tp:this.xv.bind(this),Wp:this.gm.bind(this),Ep:this.Cv.bind(this),Vp:this.Cv.bind(this),fp:this.bm.bind(this),_p:this.bm.bind(this),bp:this.Sm.bind(this),Zp:this.bv.bind(this)};this.sv=new eE(this.Mm.canvasElement,o,{Pp:()=>!this.yn.handleScroll.vertTouchDrag,kp:()=>!0})}m(){this.sv.m(),this.Mm.unsubscribeSuggestedBitmapSizeChanged(this.um),fE(this.Mm.canvasElement),this.Mm.dispose(),this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),fE(this.wm.canvasElement),this.wm.dispose(),this.Ki!==null&&this.Ki.__().u(this),this.Ki=null}fv(){return this.uv}P(){return this.Ro.fontSize}xm(){let e=this.bd.N();return this.hm!==e.k&&(this.rm.Os(),this.hm=e.k),e}Cm(){if(this.Ki===null)return 0;let e=0,t=this.xm(),n=$(this.wm.canvasElement.getContext(`2d`,{colorSpace:this.yt._m().N().layout.colorSpace}));n.save();let r=this.Ki.zl();n.font=this.ym(),r.length>0&&(e=Math.max(this.rm.Ii(n,r[0].eo),this.rm.Ii(n,r[r.length-1].eo)));let i=this.Pm();for(let t=i.length;t--;){let r=this.rm.Ii(n,i[t].ri());r>e&&(e=r)}let a=this.Ki.Lt();if(a!==null&&this.nm!==null&&(o=this.yn.crosshair).mode!==2&&o.horzLine.visible&&o.horzLine.labelVisible){let t=this.Ki.Tn(1,a),r=this.Ki.Tn(this.nm.height-2,a);e=Math.max(e,this.rm.Ii(n,this.Ki.Ji(Math.floor(Math.min(t,r))+.11111111111111,a)),this.rm.Ii(n,this.Ki.Ji(Math.ceil(Math.max(t,r))-.11111111111111,a)))}var o;n.restore();let s=e||34;return QT(Math.ceil(t.S+t.C+t.V+t.B+5+s))}km(e){this.nm!==null&&MS(this.nm,e)||(this.nm=e,this.lm=!0,this.wm.resizeCanvasElement(e),this.Mm.resizeCanvasElement(e),this.lm=!1,this.uv.style.width=`${e.width}px`,this.uv.style.height=`${e.height}px`)}Tm(){return $(this.nm).width}un(e){this.Ki!==e&&(this.Ki!==null&&this.Ki.__().u(this),this.Ki=e,e.__().i(this.wo.bind(this),this))}Ft(){return this.Ki}Os(){let e=this.yt.yv();this.yt._m().Qt().au(e,$(this.Ft()))}Rm(e){if(this.nm===null)return;let t={colorSpace:this.yt._m().N().layout.colorSpace};if(e!==1){this.Dm(),this.wm.applySuggestedBitmapSize();let e=VS(this.wm,t);e!==null&&(e.useBitmapCoordinateSpace((e=>{this.Im(e),this.Vm(e)})),this.yt.Bm(e,this.vm),this.Em(e),this.yt.Bm(e,this.fm),this.Am(e))}this.Mm.applySuggestedBitmapSize();let n=VS(this.Mm,t);n!==null&&(n.useBitmapCoordinateSpace((({context:e,bitmapSize:t})=>{e.clearRect(0,0,t.width,t.height)})),this.Lm(n),this.yt.Bm(n,this.pm))}vv(){return this.wm.bitmapSize}mv(e,t,n,r){let i=this.vv();if(i.width>0&&i.height>0&&(e.drawImage(this.wm.canvasElement,t,n),r)){let r=this.Mm.canvasElement;e.drawImage(r,t,n)}}Pt(){this.Ki?.zl()}Sv(e){if(this.Ki===null||this.Ki.Zi()||!this.yn.handleScale.axisPressedMouseMove.price)return;let t=this.yt._m().Qt(),n=this.yt.yv();this.sm=!0,t.Q_(n,this.Ki,e.localY)}xv(e){if(this.Ki===null||!this.yn.handleScale.axisPressedMouseMove.price)return;let t=this.yt._m().Qt(),n=this.yt.yv(),r=this.Ki;t.tu(n,r,e.localY)}gm(){if(this.Ki===null||!this.yn.handleScale.axisPressedMouseMove.price)return;let e=this.yt._m().Qt(),t=this.yt.yv(),n=this.Ki;this.sm&&(this.sm=!1,e.iu(t,n))}Cv(e){if(this.Ki===null||!this.yn.handleScale.axisPressedMouseMove.price)return;let t=this.yt._m().Qt(),n=this.yt.yv();this.sm=!1,t.iu(n,this.Ki)}bm(e){this.yn.handleScale.axisDoubleClickReset.price&&this.Os()}Sm(e){this.Ki!==null&&(!this.yt._m().Qt().N().handleScale.axisPressedMouseMove.price||this.Ki.je()||this.Ki.No()||this.zm(1))}bv(e){this.zm(0)}Pm(){let e=[],t=this.Ki===null?void 0:this.Ki;return(n=>{for(let r=0;r<n.length;++r){let i=n[r].qn(this.yt.yv(),t);for(let t=0;t<i.length;t++)e.push(i[t])}})(this.yt.yv().Dt()),e}Im({context:e,bitmapSize:t}){let{width:n,height:r}=t,i=this.yt.yv().Qt(),a=i.$(),o=i.af();a===o?bC(e,0,0,n,r,a):CC(e,0,0,n,r,a,o)}Vm({context:e,bitmapSize:t,horizontalPixelRatio:n}){if(this.nm===null||this.Ki===null||!this.Ki.N().borderVisible)return;e.fillStyle=this.Ki.N().borderColor;let r=Math.max(1,Math.floor(this.xm().S*n)),i;i=this.dm?t.width-r:0,e.fillRect(i,0,r,t.height)}Em(e){if(this.nm===null||this.Ki===null)return;let t=this.Ki.zl(),n=this.Ki.N(),r=this.xm(),i=this.dm?this.nm.width-r.C:0;n.borderVisible&&n.ticksVisible&&e.useBitmapCoordinateSpace((({context:e,horizontalPixelRatio:a,verticalPixelRatio:o})=>{e.fillStyle=n.borderColor;let s=Math.max(1,Math.floor(o)),c=Math.floor(.5*o),l=Math.round(r.C*a);e.beginPath();for(let n of t)e.rect(Math.floor(i*a),Math.round(n.Vl*o)-c,l,s);e.fill()})),e.useMediaCoordinateSpace((({context:e})=>{e.font=this.ym(),e.fillStyle=n.textColor??this.Ro.textColor,e.textAlign=this.dm?`right`:`left`,e.textBaseline=`middle`;let a=this.dm?Math.round(i-r.V):Math.round(i+r.C+r.V),o=t.map((t=>this.rm.Di(e,t.eo)));for(let n=t.length;n--;){let r=t[n];e.fillText(r.eo,a,r.Vl+o[n])}}))}Dm(){if(this.nm===null||this.Ki===null)return;let e=this.nm.height/2,t=[],n=this.Ki.Dt().slice(),r=this.yt.yv(),i=this.xm();this.Ki===r.Zs()&&this.yt.yv().Dt().forEach((e=>{r.Gs(e)&&n.push(e)}));let a=this.Ki.kl()[0],o=this.Ki;n.forEach((n=>{let i=n.qn(r,o);i.forEach((e=>{e.$i()&&e.Wi()===null&&(e.Ui(null),t.push(e))})),a===n&&i.length>0&&(e=i[0].Ei())})),this.Ki.N().alignLabels&&this.Om(t,i,e)}Om(e,t,n){if(this.nm===null)return;let r=e.filter((e=>e.Ei()<=n)),i=e.filter((e=>e.Ei()>n));r.sort(((e,t)=>t.Ei()-e.Ei())),r.length&&i.length&&i.push(r[0]),i.sort(((e,t)=>e.Ei()-t.Ei()));for(let n of e){let e=Math.floor(n.$t(t)/2),r=n.Ei();r>-e&&r<e&&n.Ui(e),r>this.nm.height-e&&r<this.nm.height+e&&n.Ui(this.nm.height-e)}vE(r,1,this.nm.height,t),vE(i,-1,this.nm.height,t)}Am(e){if(this.nm===null)return;let t=this.Pm(),n=this.xm(),r=this.dm?`right`:`left`;t.forEach((t=>{t.ji()&&t.Tt($(this.Ki)).st(e,n,this.rm,r)}))}Lm(e){if(this.nm===null||this.Ki===null)return;let t=this.yt._m().Qt(),n=[],r=this.yt.yv(),i=t.Vd().qn(r,this.Ki);i.length&&n.push(i);let a=this.xm(),o=this.dm?`right`:`left`;n.forEach((t=>{t.forEach((t=>{t.Tt($(this.Ki)).st(e,a,this.rm,o)}))}))}zm(e){this.uv.style.cursor=e===1?`ns-resize`:`default`}wo(){let e=this.Cm();this.am<e&&this.yt._m().Qt().ka(),this.am=e}ym(){return oC(this.Ro.fontSize,this.Ro.fontFamily)}};function bE(e,t){return e.Xa?.(t)??[]}function xE(e,t){return e.jn?.(t)??[]}function SE(e,t){return e.cn?.(t)??[]}function CE(e,t){return e.qa?.(t)??[]}var wE=class e{constructor(e,t){this.nm=Q({width:0,height:0}),this.Nm=null,this.Fm=null,this.Wm=null,this.Hm=null,this.Um=!1,this.$m=new XS,this.jm=new XS,this.qm=0,this.Ym=!1,this.Km=null,this.Gm=!1,this.Zm=null,this.Xm=null,this.lm=!1,this.om=()=>{this.lm||this.Jm===null||this.sn().mr()},this.um=()=>{this.lm||this.Jm===null||this.sn().mr()},this.Gv=e,this.Jm=t,this.Jm.mu().i(this.Qm.bind(this),this,!0),this.tw=document.createElement(`td`),this.tw.style.padding=`0`,this.tw.style.position=`relative`;let n=document.createElement(`div`);n.style.width=`100%`,n.style.height=`100%`,n.style.position=`relative`,n.style.overflow=`hidden`,this.iw=document.createElement(`td`),this.iw.style.padding=`0`,this.nw=document.createElement(`td`),this.nw.style.padding=`0`,this.tw.appendChild(n),this.wm=dE(n,Q({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om);let r=this.wm.canvasElement;r.style.position=`absolute`,r.style.zIndex=`1`,r.style.left=`0`,r.style.top=`0`,this.Mm=dE(n,Q({width:16,height:16})),this.Mm.subscribeSuggestedBitmapSizeChanged(this.um);let i=this.Mm.canvasElement;i.style.position=`absolute`,i.style.zIndex=`2`,i.style.left=`0`,i.style.top=`0`,this._v=document.createElement(`tr`),this._v.appendChild(this.iw),this._v.appendChild(this.tw),this._v.appendChild(this.nw),this.sw(),this.sv=new eE(this.Mm.canvasElement,this,{Pp:()=>this.Km===null&&!this.Gv.N().handleScroll.vertTouchDrag,kp:()=>this.Km===null&&!this.Gv.N().handleScroll.horzTouchDrag})}m(){this.Nm!==null&&this.Nm.m(),this.Fm!==null&&this.Fm.m(),this.Wm=null,this.Mm.unsubscribeSuggestedBitmapSizeChanged(this.um),fE(this.Mm.canvasElement),this.Mm.dispose(),this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),fE(this.wm.canvasElement),this.wm.dispose(),this.Jm!==null&&(this.Jm.mu().u(this),this.Jm.m()),this.sv.m()}yv(){return $(this.Jm)}ew(t){this.Jm!==null&&this.Jm.mu().u(this),this.Jm=t,this.Jm!==null&&this.Jm.mu().i(e.prototype.Qm.bind(this),this,!0),this.sw(),this.Gv.lv().indexOf(this)===this.Gv.lv().length-1?(this.Wm=this.Wm??new uE(this.tw,this.Gv),this.Wm.Pt()):(this.Wm?.Xv(),this.Wm=null)}_m(){return this.Gv}fv(){return this._v}sw(){if(this.Jm!==null&&(this.rw(),this.sn().Jn().length!==0)){if(this.Nm!==null){let e=this.Jm.X_();this.Nm.un($(e))}if(this.Fm!==null){let e=this.Jm.J_();this.Fm.un($(e))}}}hw(){this.Nm!==null&&this.Nm.Pt(),this.Fm!==null&&this.Fm.Pt()}F_(){return this.Jm===null?0:this.Jm.F_()}W_(e){this.Jm&&this.Jm.W_(e)}bp(e){if(!this.Jm)return;this.aw();let t=e.localX,n=e.localY;this.lw(t,n,e)}Fp(e){this.aw(),this.ow(),this.lw(e.localX,e.localY,e)}Sp(e){if(!this.Jm)return;this.aw();let t=e.localX,n=e.localY;this.lw(t,n,e)}Ap(e){this.Jm!==null&&(this.aw(),this.lw(e.localX,e.localY,e),this._w(e))}fp(e){this.Jm!==null&&this.uw(this.jm,e)}_p(e){this.fp(e)}Dp(e){this.aw(),this.cw(e),this.lw(e.localX,e.localY,e)}Ep(e){this.Jm!==null&&(this.aw(),this.Ym=!1,this.dw(e))}Bp(e){this.Jm!==null&&this._w(e)}Xp(e){if(this.Ym=!0,this.Km===null){let t={x:e.localX,y:e.localY};this.fw(t,t,e)}}Zp(e){this.Jm!==null&&(this.aw(),this.Jm.Qt().Rd(null),this.pw())}mw(){return this.$m}ww(){return this.jm}$p(){this.qm=1,this.sn().cs()}jp(e,t){if(!this.Gv.N().handleScale.pinch)return;let n=5*(t-this.qm);this.qm=t,this.sn().Wd(e._t,n)}Op(e){this.Ym=!1,this.Gm=this.Km!==null,this.ow();let t=this.sn().Vd();this.Km!==null&&t.It()&&(this.Zm={x:t.ni(),y:t.si()},this.Km={x:e.localX,y:e.localY})}Tp(e){if(this.Jm===null)return;let t=e.localX,n=e.localY;if(this.Km===null)this.cw(e);else{this.Gm=!1;let r=$(this.Zm),i=r.x+(t-this.Km.x),a=r.y+(n-this.Km.y);this.lw(i,a,e)}}Vp(e){this._m().N().trackingMode.exitMode===0&&(this.Gm=!0),this.Mw(),this.dw(e)}Qs(e,t){let n=this.Jm;return n===null?null:hT(n,e,t)}gw(e,t){$(t===`left`?this.Nm:this.Fm).km(Q({width:e,height:this.nm.height}))}pv(){return this.nm}km(e){MS(this.nm,e)||(this.nm=e,this.lm=!0,this.wm.resizeCanvasElement(e),this.Mm.resizeCanvasElement(e),this.lm=!1,this.tw.style.width=e.width+`px`,this.tw.style.height=e.height+`px`)}bw(){let e=$(this.Jm);e.G_(e.X_()),e.G_(e.J_());for(let t of e.kl())if(e.Gs(t)){let n=t.Ft();n!==null&&e.G_(n),t.Nn()}for(let t of e.Mu())t.Nn()}vv(){return this.wm.bitmapSize}mv(e,t,n,r){let i=this.vv();if(i.width>0&&i.height>0&&(e.drawImage(this.wm.canvasElement,t,n),r)){let r=this.Mm.canvasElement;e!==null&&e.drawImage(r,t,n)}}Rm(e){if(e===0||this.Jm===null)return;e>1&&this.bw(),this.Nm!==null&&this.Nm.Rm(e),this.Fm!==null&&this.Fm.Rm(e);let t={colorSpace:this.Gv.N().layout.colorSpace};if(e!==1){this.wm.applySuggestedBitmapSize();let e=VS(this.wm,t);e!==null&&(e.useBitmapCoordinateSpace((e=>{this.Im(e)})),this.Jm&&(this.Sw(e,bE),this.xw(e),this.Sw(e,xE),this.Sw(e,SE)))}this.Mm.applySuggestedBitmapSize();let n=VS(this.Mm,t);n!==null&&(n.useBitmapCoordinateSpace((({context:e,bitmapSize:t})=>{e.clearRect(0,0,t.width,t.height)})),this.Cw(n),this.Sw(n,CE),this.Sw(n,SE))}yw(){return this.Nm}Pw(){return this.Fm}Bm(e,t){this.Sw(e,t)}Qm(){this.Jm!==null&&this.Jm.mu().u(this),this.Jm=null}_w(e){this.uw(this.$m,e)}uw(e,t){let n=t.localX,r=t.localY;e.v()&&e.p(this.sn().Et().Vc(n),{x:n,y:r},t)}Im({context:e,bitmapSize:t}){let{width:n,height:r}=t,i=this.sn(),a=i.$(),o=i.af();a===o?bC(e,0,0,n,r,o):CC(e,0,0,n,r,a,o)}xw(e){let t=$(this.Jm),n=t.wu().wr().Tt(t);n!==null&&n.st(e,!1)}Cw(e){this.kw(e,xE,mE,this.sn().Vd())}Sw(e,t){let n=$(this.Jm),r=t===xE?this.Tw():null,i=r===null?null:this.Rw(r,n),a=n.Mu();if(i===null||r===null){let r=n._u();this.Dw(e,t,pE,a,r),this.Dw(e,t,mE,a,r);return}let o=n.Dt(),s=e=>e===r?i.Za:void 0;this.Dw(e,t,pE,a,o,s),this.Dw(e,t,mE,a,o,s),this.kw(e,t,pE,r,i.qa),this.kw(e,t,mE,r,i.qa)}Dw(e,t,n,r,i,a){for(let i of r)this.kw(e,t,n,i);if(a!==void 0)for(let r of i)this.kw(e,t,n,r,a(r));else for(let r of i)this.kw(e,t,n,r)}Tw(){let e=$(this.Jm),t=e.Qt().cu()?.uu;if(!e.Qt().N().hoveredSeriesOnTop||t===void 0)return null;for(let n of e.Dt())if(n===t)return n;return null}Rw(e,t){let n=e.Ga?.(t)??null;return n===null||n.qa.length===0?null:n}kw(e,t,n,r,i){let a=$(this.Jm),o=a.Qt().cu(),s=o!==null&&o.uu===r,c=o!==null&&s&&o.bu!==void 0?o.bu.ie:void 0,l=t=>n(t,e,s,c);i===void 0?hE(t,l,r,a):gE(i,l,a)}rw(){if(this.Jm===null)return;let e=this.Gv,t=this.Jm.X_().N().visible,n=this.Jm.J_().N().visible;t||this.Nm===null||(this.iw.removeChild(this.Nm.fv()),this.Nm.m(),this.Nm=null),n||this.Fm===null||(this.nw.removeChild(this.Fm.fv()),this.Fm.m(),this.Fm=null);let r=e.Qt().Jd();t&&this.Nm===null&&(this.Nm=new yE(this,e.N(),r,`left`),this.iw.appendChild(this.Nm.fv())),n&&this.Fm===null&&(this.Fm=new yE(this,e.N(),r,`right`),this.nw.appendChild(this.Fm.fv()))}Iw(e){return e.Jp&&this.Ym||this.Km!==null}lw(e,t,n){e=Math.max(0,Math.min(e,this.nm.width-1)),t=Math.max(0,Math.min(t,this.nm.height-1)),this.sn().Kd(e,t,n,$(this.Jm))}pw(){this.sn().Zd()}Mw(){this.Gm&&(this.Km=null,this.pw())}fw(e,t,n){this.Km=e,this.Gm=!1,this.lw(t.x,t.y,n);let r=this.sn().Vd();this.Zm={x:r.ni(),y:r.si()}}sn(){return this.Gv.Qt()}dw(e){if(!this.Um)return;let t=this.sn(),n=this.yv();if(t.eu(n,n.kn()),this.Hm=null,this.Um=!1,t.jd(),this.Xm!==null){let e=performance.now(),n=t.Et();this.Xm.me(n.Oc(),e),this.Xm.Kc(e)||t.ps(this.Xm)}}aw(){this.Km=null}ow(){if(this.Jm){if(this.sn().cs(),document.activeElement!==document.body&&document.activeElement!==document.documentElement)$(document.activeElement).blur();else{let e=document.getSelection();e!==null&&e.removeAllRanges()}!this.Jm.kn().Zi()&&this.sn().Et().Zi()}}cw(e){if(this.Jm===null)return;let t=this.sn(),n=t.Et();if(n.Zi())return;let r=this.Gv.N(),i=r.handleScroll,a=r.kineticScroll;if((!i.pressedMouseMove||e.Jp)&&(!i.horzTouchDrag&&!i.vertTouchDrag||!e.Jp))return;let o=this.Jm.kn(),s=performance.now();if(this.Hm!==null||this.Iw(e)||(this.Hm={x:e.clientX,y:e.clientY,yf:s,Vw:e.localX,Bw:e.localY}),this.Hm!==null&&!this.Um&&(this.Hm.x!==e.clientX||this.Hm.y!==e.clientY)){if(e.Jp&&a.touch||!e.Jp&&a.mouse){let e=n.ml();this.Xm=new lE(.2/e,7/e,.997,15/e),this.Xm.Uv(n.Oc(),this.Hm.yf)}else this.Xm=null;o.Zi()||t.nu(this.Jm,o,e.localY),t.Ud(e.localX),this.Um=!0}this.Um&&(o.Zi()||t.su(this.Jm,o,e.localY),t.$d(e.localX),this.Xm!==null&&this.Xm.Uv(n.Oc(),s))}},TE=class{constructor(e,t,n,r,i){this.xt=!0,this.nm=Q({width:0,height:0}),this.om=()=>this.Rm(3),this.dm=e===`left`,this.bd=n.Jd,this.yn=t,this.Ew=r,this.Aw=i,this.uv=document.createElement(`div`),this.uv.style.width=`25px`,this.uv.style.height=`100%`,this.uv.style.overflow=`hidden`,this.wm=dE(this.uv,Q({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om)}m(){this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),fE(this.wm.canvasElement),this.wm.dispose()}fv(){return this.uv}pv(){return this.nm}km(e){MS(this.nm,e)||(this.nm=e,this.wm.resizeCanvasElement(e),this.uv.style.width=`${e.width}px`,this.uv.style.height=`${e.height}px`,this.xt=!0)}Rm(e){if(e<3&&!this.xt||this.nm.width===0||this.nm.height===0)return;this.xt=!1,this.wm.applySuggestedBitmapSize();let t=VS(this.wm,{colorSpace:this.yn.layout.colorSpace});t!==null&&t.useBitmapCoordinateSpace((e=>{this.Im(e),this.Vm(e)}))}vv(){return this.wm.bitmapSize}mv(e,t,n){let r=this.vv();r.width>0&&r.height>0&&e.drawImage(this.wm.canvasElement,t,n)}Vm({context:e,bitmapSize:t,horizontalPixelRatio:n,verticalPixelRatio:r}){if(!this.Ew())return;e.fillStyle=this.yn.timeScale.borderColor;let i=Math.floor(this.bd.N().S*n),a=Math.floor(this.bd.N().S*r),o=this.dm?t.width-i:0;e.fillRect(o,0,i,a)}Im({context:e,bitmapSize:t}){bC(e,0,0,t.width,t.height,this.Aw())}};function EE(e){return t=>t.tl?.(e)??[]}var DE=EE(`normal`),OE=EE(`top`),kE=EE(`bottom`),AE=class{constructor(e,t){this.Lw=null,this.zw=null,this.M=null,this.Ow=!1,this.nm=Q({width:0,height:0}),this.Nw=new XS,this.rm=new HC(5),this.lm=!1,this.om=()=>{this.lm||this.Gv.Qt().mr()},this.um=()=>{this.lm||this.Gv.Qt().mr()},this.Gv=e,this.Pu=t,this.yn=e.N().layout,this.jv=document.createElement(`tr`),this.Fw=document.createElement(`td`),this.Fw.style.padding=`0`,this.Ww=document.createElement(`td`),this.Ww.style.padding=`0`,this.uv=document.createElement(`td`),this.uv.style.height=`25px`,this.uv.style.padding=`0`,this.Hw=document.createElement(`div`),this.Hw.style.width=`100%`,this.Hw.style.height=`100%`,this.Hw.style.position=`relative`,this.Hw.style.overflow=`hidden`,this.uv.appendChild(this.Hw),this.wm=dE(this.Hw,Q({width:16,height:16})),this.wm.subscribeSuggestedBitmapSizeChanged(this.om);let n=this.wm.canvasElement;n.style.position=`absolute`,n.style.zIndex=`1`,n.style.left=`0`,n.style.top=`0`,this.Mm=dE(this.Hw,Q({width:16,height:16})),this.Mm.subscribeSuggestedBitmapSizeChanged(this.um);let r=this.Mm.canvasElement;r.style.position=`absolute`,r.style.zIndex=`2`,r.style.left=`0`,r.style.top=`0`,this.jv.appendChild(this.Fw),this.jv.appendChild(this.uv),this.jv.appendChild(this.Ww),this.Uw(),this.Gv.Qt().N_().i(this.Uw.bind(this),this),this.sv=new eE(this.Mm.canvasElement,this,{Pp:()=>!0,kp:()=>!this.Gv.N().handleScroll.horzTouchDrag})}m(){this.sv.m(),this.Lw!==null&&this.Lw.m(),this.zw!==null&&this.zw.m(),this.Mm.unsubscribeSuggestedBitmapSizeChanged(this.um),fE(this.Mm.canvasElement),this.Mm.dispose(),this.wm.unsubscribeSuggestedBitmapSizeChanged(this.om),fE(this.wm.canvasElement),this.wm.dispose()}fv(){return this.jv}$w(){return this.Lw}jw(){return this.zw}Fp(e){if(this.Ow)return;this.Ow=!0;let t=this.Gv.Qt();!t.Et().Zi()&&this.Gv.N().handleScale.axisPressedMouseMove.time&&t.Fd(e.localX)}Op(e){this.Fp(e)}Wp(){let e=this.Gv.Qt();!e.Et().Zi()&&this.Ow&&(this.Ow=!1,this.Gv.N().handleScale.axisPressedMouseMove.time&&e.Yd())}Dp(e){let t=this.Gv.Qt();!t.Et().Zi()&&this.Gv.N().handleScale.axisPressedMouseMove.time&&t.qd(e.localX)}Tp(e){this.Dp(e)}Ep(){this.Ow=!1;let e=this.Gv.Qt();e.Et().Zi()&&!this.Gv.N().handleScale.axisPressedMouseMove.time||e.Yd()}Vp(){this.Ep()}fp(){this.Gv.N().handleScale.axisDoubleClickReset.time&&this.Gv.Qt().ws()}_p(){this.fp()}bp(){this.Gv.Qt().N().handleScale.axisPressedMouseMove.time&&this.zm(1)}Zp(){this.zm(0)}pv(){return this.nm}qw(){return this.Nw}Yw(e,t,n){MS(this.nm,e)||(this.nm=e,this.lm=!0,this.wm.resizeCanvasElement(e),this.Mm.resizeCanvasElement(e),this.lm=!1,this.uv.style.width=`${e.width}px`,this.uv.style.height=`${e.height}px`,this.Nw.p(e)),this.Lw!==null&&this.Lw.km(Q({width:t,height:e.height})),this.zw!==null&&this.zw.km(Q({width:n,height:e.height}))}Kw(){let e=this.Gw();return Math.ceil(e.S+e.C+e.P+e.A+e.I+e.Zw)}Pt(){this.Gv.Qt().Et().zl()}vv(){return this.wm.bitmapSize}mv(e,t,n,r){let i=this.vv();if(i.width>0&&i.height>0&&(e.drawImage(this.wm.canvasElement,t,n),r)){let r=this.Mm.canvasElement;e.drawImage(r,t,n)}}Rm(e){if(e===0)return;let t={colorSpace:this.yn.colorSpace};if(e!==1){this.wm.applySuggestedBitmapSize();let n=VS(this.wm,t);n!==null&&(n.useBitmapCoordinateSpace((e=>{this.Im(e),this.Vm(e),this.Xw(n,kE)})),this.Em(n),this.Xw(n,DE)),this.Lw!==null&&this.Lw.Rm(e),this.zw!==null&&this.zw.Rm(e)}this.Mm.applySuggestedBitmapSize();let n=VS(this.Mm,t);n!==null&&(n.useBitmapCoordinateSpace((({context:e,bitmapSize:t})=>{e.clearRect(0,0,t.width,t.height)})),this.Jw([...this.Gv.Qt().Jn(),this.Gv.Qt().Vd()],n),this.Xw(n,OE))}Xw(e,t){let n=this.Gv.Qt().Jn();for(let r of n)hE(t,(t=>pE(t,e,!1,void 0)),r,void 0);for(let r of n)hE(t,(t=>mE(t,e,!1,void 0)),r,void 0)}Im({context:e,bitmapSize:t}){bC(e,0,0,t.width,t.height,this.Gv.Qt().af())}Vm({context:e,bitmapSize:t,verticalPixelRatio:n}){if(this.Gv.N().timeScale.borderVisible){e.fillStyle=this.Qw();let r=Math.max(1,Math.floor(this.Gw().S*n));e.fillRect(0,0,t.width,r)}}Em(e){let t=this.Gv.Qt().Et(),n=t.zl();if(!n||n.length===0)return;let r=this.Pu.maxTickMarkWeight(n),i=this.Gw(),a=t.N();a.borderVisible&&a.ticksVisible&&e.useBitmapCoordinateSpace((({context:e,horizontalPixelRatio:t,verticalPixelRatio:r})=>{e.strokeStyle=this.Qw(),e.fillStyle=this.Qw();let a=Math.max(1,Math.floor(t)),o=Math.floor(.5*t);e.beginPath();let s=Math.round(i.C*r);for(let r=n.length;r--;){let i=Math.round(n[r].coord*t);e.rect(i-o,0,a,s)}e.fill()})),e.useMediaCoordinateSpace((({context:e})=>{let t=i.S+i.C+i.A+i.P/2;e.textAlign=`center`,e.textBaseline=`middle`,e.fillStyle=this.H(),e.font=this.ym();for(let i of n)if(i.weight<r){let n=i.needAlignCoordinate?this.tM(e,i.coord,i.label):i.coord;e.fillText(i.label,n,t)}this.Gv.N().timeScale.allowBoldLabels&&(e.font=this.iM());for(let i of n)if(i.weight>=r){let n=i.needAlignCoordinate?this.tM(e,i.coord,i.label):i.coord;e.fillText(i.label,n,t)}}))}tM(e,t,n){let r=this.rm.Ii(e,n),i=r/2,a=Math.floor(t-i)+.5;return a<0?t+=Math.abs(0-a):a+r>this.nm.width&&(t-=Math.abs(this.nm.width-(a+r))),t}Jw(e,t){let n=this.Gw();for(let r of e)for(let e of r.dn())e.Tt().st(t,n)}Qw(){return this.Gv.N().timeScale.borderColor}H(){return this.yn.textColor}F(){return this.yn.fontSize}ym(){return oC(this.F(),this.yn.fontFamily)}iM(){return oC(this.F(),this.yn.fontFamily,`bold`)}Gw(){this.M===null&&(this.M={S:1,L:NaN,A:NaN,I:NaN,tn:NaN,C:5,P:NaN,k:``,Qi:new HC,Zw:0});let e=this.M,t=this.ym();if(e.k!==t){let n=this.F();e.P=n,e.k=t,e.A=3*n/12,e.I=3*n/12,e.tn=9*n/12,e.L=0,e.Zw=4*n/12,e.Qi.Os()}return this.M}zm(e){this.uv.style.cursor=e===1?`ew-resize`:`default`}Uw(){let e=this.Gv.Qt(),t=e.N();t.leftPriceScale.visible||this.Lw===null||(this.Fw.removeChild(this.Lw.fv()),this.Lw.m(),this.Lw=null),t.rightPriceScale.visible||this.zw===null||(this.Ww.removeChild(this.zw.fv()),this.zw.m(),this.zw=null);let n={Jd:this.Gv.Qt().Jd()},r=()=>t.leftPriceScale.borderVisible&&e.Et().N().borderVisible,i=()=>e.af();t.leftPriceScale.visible&&this.Lw===null&&(this.Lw=new TE(`left`,t,n,r,i),this.Fw.appendChild(this.Lw.fv())),t.rightPriceScale.visible&&this.zw===null&&(this.zw=new TE(`right`,t,n,r,i),this.Ww.appendChild(this.zw.fv()))}},jE=!!JT&&!!navigator.userAgentData&&navigator.userAgentData.brands.some((e=>e.brand.includes(`Chromium`)))&&!!JT&&(navigator?.userAgentData?.platform?navigator.userAgentData.platform===`Windows`:navigator.userAgent.toLowerCase().indexOf(`win`)>=0),ME=class{constructor(e,t,n){var r;this.nM=[],this.sM=[],this.eM=0,this.oo=0,this.k_=0,this.rM=0,this.hM=0,this.aM=null,this.lM=!1,this.$m=new XS,this.jm=new XS,this.wd=new XS,this.oM=null,this._M=null,this.Kv=e,this.yn=t,this.Pu=n,this.jv=document.createElement(`div`),this.jv.classList.add(`tv-lightweight-charts`),this.jv.style.overflow=`hidden`,this.jv.style.direction=`ltr`,this.jv.style.width=`100%`,this.jv.style.height=`100%`,(r=this.jv).style.userSelect=`none`,r.style.webkitUserSelect=`none`,r.style.msUserSelect=`none`,r.style.MozUserSelect=`none`,r.style.webkitTapHighlightColor=`transparent`,this.uM=document.createElement(`table`),this.uM.setAttribute(`cellspacing`,`0`),this.jv.appendChild(this.uM),this.cM=this.dM.bind(this),NE(this.yn)&&this.fM(!0),this.sn=new OT(this.gd.bind(this),this.yn,n),this.Qt().Bd().i(this.pM.bind(this),this),this.vM=new AE(this,this.Pu),this.uM.appendChild(this.vM.fv());let i=t.autoSize&&this.mM(),a=this.yn.width,o=this.yn.height;if(i||a===0||o===0){let t=e.getBoundingClientRect();a||=t.width,o||=t.height}this.wM(a,o),this.MM(),e.appendChild(this.jv),this.gM(),this.sn.Et().Jc().i(this.sn.ka.bind(this.sn),this),this.sn.N_().i(this.sn.ka.bind(this.sn),this)}Qt(){return this.sn}N(){return this.yn}lv(){return this.nM}bM(){return this.vM}m(){this.fM(!1),this.eM!==0&&window.cancelAnimationFrame(this.eM),this.sn.Bd().u(this),this.sn.Et().Jc().u(this),this.sn.N_().u(this),this.sn.m();for(let e of this.nM)this.uM.removeChild(e.fv()),e.mw().u(this),e.ww().u(this),e.m();this.nM=[];for(let e of this.sM)this.SM(e);this.sM=[],$(this.vM).m(),this.jv.parentElement!==null&&this.jv.parentElement.removeChild(this.jv),this.wd.m(),this.$m.m(),this.jm.m(),this.xM()}wM(e,t,n=!1){if(this.oo===t&&this.k_===e)return;let r=function(e){let t=Math.floor(e.width),n=Math.floor(e.height);return Q({width:t-t%2,height:n-n%2})}(Q({width:e,height:t}));this.oo=r.height,this.k_=r.width;let i=this.oo+`px`,a=this.k_+`px`;if(this.CM()||($(this.jv).style.height=i,$(this.jv).style.width=a),this.uM.style.height=i,this.uM.style.width=a,n){this.eM!==0&&(window.cancelAnimationFrame(this.eM),this.eM=0),this.lM=!1;let e=PC.ys();this.aM!==null&&(e.Ss(this.aM),this.aM=null),this.yM(e,performance.now())}else this.sn.ka()}Rm(e){e===void 0&&(e=PC.ys());for(let t=0;t<this.nM.length;t++)this.nM[t].Rm(e._s(t).rs);this.yn.timeScale.visible&&this.vM.Rm(e.ls())}vr(e){let t=NE(this.yn);this.sn.vr(e);let n=NE(this.yn);n!==t&&this.fM(n),e.layout?.panes&&this.PM(),this.gM(),this.kM(e)}mw(){return this.$m}ww(){return this.jm}Bd(){return this.wd}TM(e=!1){this.aM!==null&&(this.yM(this.aM,performance.now()),this.aM=null);let t=this.RM(null),n=document.createElement(`canvas`);n.width=t.width,n.height=t.height;let r=$(n.getContext(`2d`));return this.RM(r,e),n}DM(e){return e===`left`&&!this.IM()||e===`right`&&!this.VM()||this.nM.length===0?0:$(e===`left`?this.nM[0].yw():this.nM[0].Pw()).Tm()}CM(){return this.yn.autoSize&&this.oM!==null}Mv(){return this.jv}BM(e){this._M=e,this._M?this.Mv().style.setProperty(`cursor`,e):this.Mv().style.removeProperty(`cursor`)}EM(){return this._M}AM(e){return JS(this.nM[e]).pv()}PM(){this.sM.forEach((e=>{e.Pt()}))}kM(e){(e.autoSize!==void 0||!this.oM||e.width===void 0&&e.height===void 0)&&(e.autoSize&&!this.oM&&this.mM(),!1===e.autoSize&&this.oM!==null&&this.xM(),e.autoSize||e.width===void 0&&e.height===void 0||this.wM(e.width||this.k_,e.height||this.oo))}RM(e,t){let n=0,r=0,i=this.nM[0],a=(n,r)=>{let i=0;for(let a=0;a<this.nM.length;a++){let o=this.nM[a],s=$(n===`left`?o.yw():o.Pw()),c=s.vv();if(e!==null&&s.mv(e,r,i,t),i+=c.height,a<this.nM.length-1){let t=this.sM[a],n=t.vv();e!==null&&t.mv(e,r,i),i+=n.height}}};this.IM()&&(a(`left`,0),n+=$(i.yw()).vv().width);for(let i=0;i<this.nM.length;i++){let a=this.nM[i],o=a.vv();if(e!==null&&a.mv(e,n,r,t),r+=o.height,i<this.nM.length-1){let t=this.sM[i],a=t.vv();e!==null&&t.mv(e,n,r),r+=a.height}}n+=i.vv().width,this.VM()&&(a(`right`,n),n+=$(i.Pw()).vv().width);let o=(t,n,r)=>{$(t===`left`?this.vM.$w():this.vM.jw()).mv($(e),n,r)};if(this.yn.timeScale.visible){let n=this.vM.vv();if(e!==null){let a=0;this.IM()&&(o(`left`,a,r),a=$(i.yw()).vv().width),this.vM.mv(e,a,r,t),a+=n.width,this.VM()&&o(`right`,a,r)}r+=n.height}return Q({width:n,height:r})}LM(){let e=0,t=0,n=0;for(let r of this.nM)this.IM()&&(t=Math.max(t,$(r.yw()).Cm(),this.yn.leftPriceScale.minimumWidth)),this.VM()&&(n=Math.max(n,$(r.Pw()).Cm(),this.yn.rightPriceScale.minimumWidth)),e+=r.F_();t=QT(t),n=QT(n);let r=this.k_,i=this.oo,a=Math.max(r-t-n,0),o=1*this.sM.length,s=this.yn.timeScale.visible,c=s?Math.max(this.vM.Kw(),this.yn.timeScale.minimumHeight):0;var l;c=(l=c)+l%2;let u=o+c,d=i<u?0:i-u,f=d/e,p=0,m=window.devicePixelRatio||1;for(let e=0;e<this.nM.length;++e){let r=this.nM[e];r.ew(this.sn.Gn()[e]);let i=0,o=0;o=e===this.nM.length-1?Math.ceil((d-p)*m)/m:Math.round(r.F_()*f*m)/m,i=Math.max(o,2),p+=i,r.km(Q({width:a,height:i})),this.IM()&&r.gw(t,`left`),this.VM()&&r.gw(n,`right`),r.yv()&&this.sn.Ed(r.yv(),i)}this.vM.Yw(Q({width:s?a:0,height:c}),s?t:0,s?n:0),this.sn.H_(a),this.rM!==t&&(this.rM=t),this.hM!==n&&(this.hM=n)}fM(e){e?this.jv.addEventListener(`wheel`,this.cM,{passive:!1}):this.jv.removeEventListener(`wheel`,this.cM)}zM(e){switch(e.deltaMode){case e.DOM_DELTA_PAGE:return 120;case e.DOM_DELTA_LINE:return 32}return jE?1/window.devicePixelRatio:1}dM(e){if(!(e.deltaX!==0&&this.yn.handleScroll.mouseWheel||e.deltaY!==0&&this.yn.handleScale.mouseWheel))return;let t=this.zM(e),n=t*e.deltaX/100,r=-t*e.deltaY/100;if(e.cancelable&&e.preventDefault(),r!==0&&this.yn.handleScale.mouseWheel){let t=Math.sign(r)*Math.min(1,Math.abs(r)),n=e.clientX-this.jv.getBoundingClientRect().left;this.Qt().Wd(n,t)}n!==0&&this.yn.handleScroll.mouseWheel&&this.Qt().Hd(-80*n)}yM(e,t){let n=e.ls();n===3&&this.OM(),n!==3&&n!==2||(this.NM(e),this.FM(e,t),this.vM.Pt(),this.nM.forEach((e=>{e.hw()})),this.aM?.ls()===3&&(this.aM.Ss(e),this.OM(),this.NM(this.aM),this.FM(this.aM,t),e=this.aM,this.aM=null)),this.Rm(e)}FM(e,t){for(let n of e.bs())this.xs(n,t)}NM(e){let t=this.sn.Gn();for(let n=0;n<t.length;n++)e._s(n).hs&&t[n].lu()}xs(e,t){let n=this.sn.Et();switch(e.ds){case 0:n.td();break;case 1:n.nd(e.Wt);break;case 2:n.Ms(e.Wt);break;case 3:n.gs(e.Wt);break;case 4:n.Wc();break;case 5:e.Wt.Kc(t)||n.gs(e.Wt.Gc(t))}}gd(e){this.aM===null?this.aM=e:this.aM.Ss(e),this.lM||(this.lM=!0,this.eM=window.requestAnimationFrame((e=>{if(this.lM=!1,this.eM=0,this.aM!==null){let t=this.aM;this.aM=null,this.yM(t,e);for(let n of t.bs())if(n.ds===5&&!n.Wt.Kc(e)){this.Qt().ps(n.Wt);break}}})))}OM(){this.MM()}SM(e){this.uM.removeChild(e.fv()),e.m()}MM(){let e=this.sn.Gn(),t=e.length,n=this.nM.length;for(let e=t;e<n;e++){let e=JS(this.nM.pop());this.uM.removeChild(e.fv()),e.mw().u(this),e.ww().u(this),e.m();let t=this.sM.pop();t!==void 0&&this.SM(t)}for(let r=n;r<t;r++){let t=new wE(this,e[r]);if(t.mw().i(this.WM.bind(this,t),this),t.ww().i(this.HM.bind(this,t),this),this.nM.push(t),r>0){let e=new oE(this,r-1,r);this.sM.push(e),this.uM.insertBefore(e.fv(),this.vM.fv())}this.uM.insertBefore(t.fv(),this.vM.fv())}for(let n=0;n<t;n++){let t=e[n],r=this.nM[n];r.yv()===t?r.sw():r.ew(t)}this.gM(),this.LM()}UM(e,t,n,r){let i=new Map;e!==null&&this.sn.Jn().forEach((t=>{let n=t.Un().Hn(e);n!==null&&i.set(t,n)}));let a;if(e!==null){let t=this.sn.Et().en(e)?.originalTime;t!==void 0&&(a=t)}let o=this.Qt().cu(),s=this.$M(r),c=function(e,t){let n=e!==null&&e.uu instanceof Fw?e.uu:void 0,r=e?.bu?.te,i=t!==void 0&&t!==-1?t:void 0;return e===null||e.ee===void 0?{jM:n,qM:r}:{jM:n,qM:r,YM:{ds:e.ee,KM:(a=e.uu,o=e.ee,a instanceof cT?`pane-primitive`:o===`marker`||o===`primitive`?`series-primitive`:`series`),GM:ZT(e.ee,r),Y_:n,ZM:r,XM:i}};var a,o}(o,s);return{Qr:a,$n:e??void 0,JM:t??void 0,XM:s===-1?void 0:s,jM:c.jM,QM:i,qM:c.qM,YM:c.YM,tg:n??void 0}}$M(e){let t=-1;if(e)t=this.nM.indexOf(e);else{let e=this.Qt().Vd().Kn();e!==null&&(t=this.Qt().Gn().indexOf(e))}return t}WM(e,t,n,r){this.$m.p((()=>this.UM(t,n,r,e)))}HM(e,t,n,r){this.jm.p((()=>this.UM(t,n,r,e)))}pM(e,t,n){this.BM(this.Qt().cu()?.gu??null),this.wd.p((()=>this.UM(e,t,n)))}gM(){let e=this.yn.timeScale.visible?``:`none`;this.vM.fv().style.display=e}IM(){return this.nM[0].yv().X_().N().visible}VM(){return this.nM[0].yv().J_().N().visible}mM(){return`ResizeObserver`in window&&(this.oM=new ResizeObserver((e=>{let t=e[e.length-1];if(!t)return;let n=t.contentRect.width,r=t.contentRect.height;this.wM(n,r,!0)})),this.oM.observe(this.Kv,{box:`border-box`}),!0)}xM(){this.oM!==null&&this.oM.disconnect(),this.oM=null}};function NE(e){return!!(e.handleScroll.mouseWheel||e.handleScale.mouseWheel)}function PE(e){return e.open===void 0&&e.value===void 0}function FE(e){return function(e){return e.open!==void 0}(e)||function(e){return e.value!==void 0}(e)}function IE(e,t,n,r){let i=n.value,a={$n:t,wt:e,Wt:[i,i,i,i],Qr:r};return n.color!==void 0&&(a.R=n.color),a}function LE(e,t,n,r){let i=n.value,a={$n:t,wt:e,Wt:[i,i,i,i],Qr:r};return n.lineColor!==void 0&&(a.vt=n.lineColor),n.topColor!==void 0&&(a.ah=n.topColor),n.bottomColor!==void 0&&(a.oh=n.bottomColor),a}function RE(e,t,n,r){let i=n.value,a={$n:t,wt:e,Wt:[i,i,i,i],Qr:r};return n.topLineColor!==void 0&&(a._h=n.topLineColor),n.bottomLineColor!==void 0&&(a.uh=n.bottomLineColor),n.topFillColor1!==void 0&&(a.dh=n.topFillColor1),n.topFillColor2!==void 0&&(a.fh=n.topFillColor2),n.bottomFillColor1!==void 0&&(a.ph=n.bottomFillColor1),n.bottomFillColor2!==void 0&&(a.mh=n.bottomFillColor2),a}function zE(e,t,n,r){let i={$n:t,wt:e,Wt:[n.open,n.high,n.low,n.close],Qr:r};return n.color!==void 0&&(i.R=n.color),i}function BE(e,t,n,r){let i={$n:t,wt:e,Wt:[n.open,n.high,n.low,n.close],Qr:r};return n.color!==void 0&&(i.R=n.color),n.borderColor!==void 0&&(i.Ht=n.borderColor),n.wickColor!==void 0&&(i.hh=n.wickColor),i}function VE(e,t,n,r,i){let a=JS(i)(n),o=Math.max(...a),s=Math.min(...a),c=a[a.length-1],l=[c,o,s,c],{time:u,color:d,...f}=n;return{$n:t,wt:e,Wt:l,Qr:r,ue:f,R:d}}function HE(e){return e.Wt!==void 0}function UE(e,t){return t.customValues!==void 0&&(e.ig=t.customValues),e}function WE(e){return(t,n,r,i,a,o)=>function(e,t){return t?t(e):PE(e)}(r,o)?UE({wt:t,$n:n,Qr:i},r):UE(e(t,n,r,i,a),r)}function GE(e){return{Candlestick:WE(BE),Bar:WE(zE),Area:WE(LE),Baseline:WE(RE),Histogram:WE(IE),Line:WE(IE),Custom:WE(VE)}[e]}function KE(e){return{$n:0,ng:new Map,Oa:e}}function qE(e,t){if(e!==void 0&&e.length!==0)return{sg:t.key(e[0].wt),eg:t.key(e[e.length-1].wt)}}function JE(e){let t;return e.forEach((e=>{t===void 0&&(t=e.Qr)})),JS(t)}var YE=class{constructor(e){this.rg=new Map,this.hg=new Map,this.ag=new Map,this.lg=[],this.Pu=e}m(){this.rg.clear(),this.hg.clear(),this.ag.clear(),this.lg=[]}og(e,t){let n=this.rg.size!==0,r=!1,i=this.hg.get(e);if(i!==void 0){if(this.hg.size===1)n=!1,r=!0,this.rg.clear();else for(let t of this.lg)t.pointData.ng.delete(e)&&(r=!0)}let a=[];if(t.length!==0){let n=t.map((e=>e.time)),i=this.Pu.createConverterToInternalObj(t),o=GE(e.bh()),s=e.ul(),c=e.cl();a=t.map(((t,a)=>{let l=i(t.time),u=this.Pu.key(l),d=this.rg.get(u);d===void 0&&(d=KE(l),this.rg.set(u,d),r=!0);let f=o(l,d.$n,t,n[a],s,c);return d.ng.set(e,f),f}))}n&&this._g(),this.ug(e,a);let o=-1;if(r){let e=[];this.rg.forEach((t=>{e.push({timeWeight:0,time:t.Oa,pointData:t,originalTime:JE(t.ng)})})),e.sort(((e,t)=>this.Pu.key(e.time)-this.Pu.key(t.time))),o=this.cg(e)}return this.dg(e,o,function(e,t,n){let r=qE(e,n),i=qE(t,n);if(r!==void 0&&i!==void 0)return{fg:!1,Va:r.eg>=i.eg&&r.sg>=i.sg}}(this.hg.get(e),i,this.Pu))}if(e){return this.og(e,[])}pg(e,t,n){if(n&&e.Fa())throw Error(`Historical updates are not supported when conflation is enabled. Conflation requires data to be processed in order.`);let r=t;(function(e){e.Qr===void 0&&(e.Qr=e.time)})(r),this.Pu.preprocessData(t);let i=this.Pu.createConverterToInternalObj([t])(t.time),a=this.ag.get(e);if(!n&&a!==void 0&&this.Pu.key(i)<this.Pu.key(a))throw Error(`Cannot update oldest data, last time=${a}, new time=${i}`);let o=this.rg.get(this.Pu.key(i));if(n&&o===void 0)throw Error(`Cannot update non-existing data point when historicalUpdate is true`);let s=o===void 0;o===void 0&&(o=KE(i),this.rg.set(this.Pu.key(i),o));let c=GE(e.bh()),l=e.ul(),u=e.cl(),d=c(i,o.$n,t,r.Qr,l,u),f=!n&&!s&&a!==void 0&&this.Pu.key(i)===this.Pu.key(a);o.ng.set(e,d),n?this.vg(e,d,o.$n):(f&&e.Fa()&&HE(d)&&e.Rr(d),this.mg(e,d));let p={Va:HE(d),fg:n};if(!s)return this.dg(e,-1,p);let m={timeWeight:0,time:o.Oa,pointData:o,originalTime:JE(o.ng)},h=fw(this.lg,this.Pu.key(m.time),((e,t)=>this.Pu.key(e.time)<t));this.lg.splice(h,0,m);for(let e=h;e<this.lg.length;++e)XE(this.lg[e].pointData,e);return this.Pu.fillWeightsForPoints(this.lg,h),this.dg(e,h,p)}wg(e,t){let n=this.hg.get(e);if(n===void 0||t<=0)return[[],this.Mg()];t=Math.min(t,n.length);let r=n.splice(-t).reverse();n.length===0?this.ag.delete(e):this.ag.set(e,n[n.length-1].wt);for(let t of r){let n=this.rg.get(this.Pu.key(t.wt));if(n&&(n.ng.delete(e),n.ng.size===0)){this.rg.delete(this.Pu.key(n.Oa)),this.lg.splice(n.$n,1);for(let e=n.$n;e<this.lg.length;++e)XE(this.lg[e].pointData,e)}}return[r,this.dg(e,this.lg.length-1,{fg:!1,Va:!1})]}mg(e,t){let n=this.hg.get(e);n===void 0&&(n=[],this.hg.set(e,n));let r=n.length===0?null:n[n.length-1];r===null||this.Pu.key(t.wt)>this.Pu.key(r.wt)?HE(t)&&n.push(t):HE(t)?n[n.length-1]=t:n.splice(-1,1),this.ag.set(e,t.wt)}vg(e,t,n){let r=this.hg.get(e);if(r===void 0)return;let i=fw(r,n,((e,t)=>e.$n<t));HE(t)?r[i]=t:r.splice(i,1)}ug(e,t){t.length===0?(this.hg.delete(e),this.ag.delete(e)):(this.hg.set(e,t.filter(HE)),this.ag.set(e,t[t.length-1].wt))}_g(){for(let e of this.lg)e.pointData.ng.size===0&&this.rg.delete(this.Pu.key(e.time))}cg(e){let t=-1;for(let n=0;n<this.lg.length&&n<e.length;++n){let r=this.lg[n],i=e[n];if(this.Pu.key(r.time)!==this.Pu.key(i.time)){t=n;break}i.timeWeight=r.timeWeight,XE(i.pointData,n)}if(t===-1&&this.lg.length!==e.length&&(t=Math.min(this.lg.length,e.length)),t===-1)return-1;for(let n=t;n<e.length;++n)XE(e[n].pointData,n);return this.Pu.fillWeightsForPoints(e,t),this.lg=e,t}gg(){if(this.hg.size===0)return null;let e=0;return this.hg.forEach((t=>{t.length!==0&&(e=Math.max(e,t[t.length-1].$n))})),e}dg(e,t,n){let r=this.Mg();if(t!==-1)this.hg.forEach(((t,i)=>{r.Y_.set(i,{ue:t,bg:i===e?n:void 0})})),this.hg.has(e)||r.Y_.set(e,{ue:[],bg:n}),r.Et.Sg=this.lg,r.Et.xg=t;else{let t=this.hg.get(e);r.Y_.set(e,{ue:t||[],bg:n})}return r}Mg(){return{Y_:new Map,Et:{Dc:this.gg()}}}};function XE(e,t){e.$n=t,e.ng.forEach((e=>{e.$n=t}))}function ZE(e,t){return e._t<t}function QE(e,t){return t<e._t}function $E(e,t,n,r){return fw(e,t,ZE,n,r)}function eD(e,t,n,r){return pw(e,t,QE,n,r)}function tD(e,t,n){return{ne:e,se:t,ee:n}}var nD=[0,0];function rD(e,t,n){return t===void 0||t.wt!==e.wt-1?e._t-n/2:(t._t+e._t)/2}function iD(e,t,n){return t===void 0||t.wt!==e.wt+1?e._t+n/2:(e._t+t._t)/2}function aD(e,t,n,r,i,a,o){if(t===null||t.from>=t.to||e.length===0)return null;let s=i/2+a,c=$E(e,n-s,t.from,t.to),l=eD(e,n+s,c,t.to);if(c>=l)return null;let u=1/0;for(let s=c;s<l;s++){let c=e[s],l=s>t.from?e[s-1]:void 0,d=s<t.to-1?e[s+1]:void 0,f=rD(c,l,i)-a,p=iD(c,d,i)+a;if(n<f||n>p)continue;o(c,nD);let m=nD[0],h=nD[1],g=Math.min(m,h),_=Math.max(m,h),v=g-a,y=_+a;if(r>=g&&r<=_)u=Math.min(u,0);else if(r>=v&&r<=y){let e=Math.min(Math.abs(r-g),Math.abs(_-r));u=Math.min(u,e)}}return Number.isFinite(u)?tD(u,0,`series-range`):null}function oD(e,t){return e.wt<t}function sD(e,t){return t<e.wt}function cD(e,t,n){let r=t.Na(),i=t.bi(),a=fw(e,r,oD),o=pw(e,i,sD);if(!n)return{from:a,to:o};let s=a,c=o;return a>0&&a<e.length&&e[a].wt>=r&&(s=a-1),o>0&&o<e.length&&e[o-1].wt<=i&&(c=o+1),{from:s,to:c}}var lD=class{constructor(e,t,n){this.Cg=!0,this.yg=!0,this.Pg=!0,this.kg=[],this.Tg=null,this.Rg=-1,this.ae=e,this.le=t,this.Dg=n}Pt(e){this.Cg=!0,e===`data`&&(this.yg=!0),e===`options`&&(this.Pg=!0)}Tt(){return this.ae.It()?(this.Ig(),this.Tg===null?null:this.Vg):null}Qs(e,t){return this.ae.It()?(this.Ig(),this.Tg===null?null:this.Bg(e,t)):null}Bg(e,t){return null}Eg(){this.kg=this.kg.map((e=>({...e,...this.ae.Sa().Sh(e.wt)})))}Ag(){this.Tg=null}Ig(){let e=this.le.Et(),t=e.N().enableConflation?e.sd():0;t!==this.Rg&&(this.yg=!0,this.Rg=t),this.yg&&=(this.Lg(),!1),this.Pg&&=(this.Eg(),!1),this.Cg&&=(this.zg(),!1)}zg(){let e=this.ae.Ft(),t=this.le.Et();if(this.Ag(),t.Zi()||e.Zi())return;let n=t.Ee();if(n===null||this.ae.Un().Th()===0)return;let r=this.ae.Lt();r!==null&&(this.Tg=cD(this.kg,n,this.Dg),this.Og(e,t,r.Wt),this.Ng())}},uD=class{constructor(e,t){this.Fg=e,this.Ki=t}st(e,t,n){this.Fg.draw(e,this.Ki,t,n)}};function dD(e){switch(e){case`point`:return 2;case`range`:return 0;default:return 1}}var fD=class extends lD{constructor(e,t,n){super(e,t,!1),this.Yh=n,this.Fg=this.Yh.renderer(),this.Vg=new uD(this.Fg,(e=>this.Wg(e)))}get ga(){return this.Yh.conflationReducer}Ha(e){return this.Yh.priceValueBuilder(e)}dl(e){return this.Yh.isWhitespace(e)}Bg(e,t){let n=this.Fg.hitTest?.(e,t,(e=>this.Wg(e)));if(n!=null)return{ne:(r=n).distance,se:dD(r.type),ee:`custom`,gu:r.cursorStyle,te:r.objectId,ie:r.hitTestData};var r;let i=aD(this.kg,this.Tg,e,t,this.le.Et().ml(),this.ae.N().hitTestTolerance,((e,t)=>{let n=e.Hg,r=NaN,i=NaN;if(n!==void 0&&!this.Yh.isWhitespace(n))for(let e of this.Yh.priceValueBuilder(n)){let t=this.Wg(e);t!==null&&(r=Number.isNaN(r)?t:Math.min(r,t),i=Number.isNaN(i)?t:Math.max(i,t))}t[0]=r,t[1]=i}));return i===null?null:{...i,ee:`custom`}}Lg(){let e=this.ae.Sa();this.kg=this.ae.Ua().Bh().map((t=>({wt:t.$n,_t:NaN,...e.Sh(t.$n),Hg:t.ue})))}Og(e,t){t.Ic(this.kg,iC(this.Tg))}Ng(){this.Yh.update({bars:this.kg.map(pD),barSpacing:this.le.Et().ml(),visibleRange:this.Tg,conflationFactor:this.le.Et().sd()},this.ae.N())}Wg(e){let t=this.ae.Lt();return t===null?null:this.ae.Ft().Nt(e,t.Wt)}};function pD(e){return{x:e._t,time:e.wt,originalData:e.Hg,barColor:e.sh}}var mD={color:`#2196f3`},hD=(e,t,n)=>new fD(e,t,YS(n));function gD(e){let t={value:e.Wt[3],time:e.Qr};return e.ig!==void 0&&(t.customValues=e.ig),t}function _D(e){let t=gD(e);return e.R!==void 0&&(t.color=e.R),t}function vD(e){let t=gD(e);return e.vt!==void 0&&(t.lineColor=e.vt),e.ah!==void 0&&(t.topColor=e.ah),e.oh!==void 0&&(t.bottomColor=e.oh),t}function yD(e){let t=gD(e);return e._h!==void 0&&(t.topLineColor=e._h),e.uh!==void 0&&(t.bottomLineColor=e.uh),e.dh!==void 0&&(t.topFillColor1=e.dh),e.fh!==void 0&&(t.topFillColor2=e.fh),e.ph!==void 0&&(t.bottomFillColor1=e.ph),e.mh!==void 0&&(t.bottomFillColor2=e.mh),t}function bD(e){let t={open:e.Wt[0],high:e.Wt[1],low:e.Wt[2],close:e.Wt[3],time:e.Qr};return e.ig!==void 0&&(t.customValues=e.ig),t}function xD(e){let t=bD(e);return e.R!==void 0&&(t.color=e.R),t}function SD(e){let t=bD(e),{R:n,Ht:r,hh:i}=e;return n!==void 0&&(t.color=n),r!==void 0&&(t.borderColor=r),i!==void 0&&(t.wickColor=i),t}function CD(e){return{Area:vD,Line:_D,Baseline:yD,Histogram:_D,Bar:xD,Candlestick:SD,Custom:wD}[e]}function wD(e){let t=e.Qr;return{...e.ue,time:t}}var TD={vertLine:{color:`#9598A1`,width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:`#131722`},horzLine:{color:`#9598A1`,width:1,style:3,visible:!0,labelVisible:!0,labelBackgroundColor:`#131722`},mode:1,doNotSnapToHiddenSeriesIndices:!1},ED={vertLines:{color:`#D6DCDE`,style:0,visible:!0},horzLines:{color:`#D6DCDE`,style:0,visible:!0}},DD={background:{type:`solid`,color:`#FFFFFF`},textColor:`#191919`,fontSize:12,fontFamily:aC,panes:{enableResize:!0,separatorColor:`#E0E3EB`,separatorHoverColor:`rgba(178, 181, 189, 0.2)`},attributionLogo:!0,colorSpace:`srgb`,colorParsers:[]},OD={autoScale:!0,mode:0,invertScale:!1,alignLabels:!0,borderVisible:!0,borderColor:`#2B2B43`,entireTextOnly:!1,visible:!1,ticksVisible:!1,scaleMargins:{bottom:.1,top:.2},minimumWidth:0,ensureEdgeTickMarksVisible:!1,tickMarkDensity:2.5},kD={rightOffset:0,barSpacing:6,minBarSpacing:.5,maxBarSpacing:0,fixLeftEdge:!1,fixRightEdge:!1,lockVisibleTimeRangeOnResize:!1,rightBarStaysOnScroll:!1,borderVisible:!0,borderColor:`#2B2B43`,visible:!0,timeVisible:!1,secondsVisible:!0,shiftVisibleRangeOnNewBar:!0,allowShiftVisibleRangeOnWhitespaceReplacement:!1,ticksVisible:!1,uniformDistribution:!1,minimumHeight:0,allowBoldLabels:!0,ignoreWhitespaceIndices:!1,enableConflation:!1,conflationThresholdFactor:1,precomputeConflationOnInit:!1,precomputeConflationPriority:`background`};function AD(){return{addDefaultPane:!0,hoveredSeriesOnTop:!0,width:0,height:0,autoSize:!1,layout:DD,crosshair:TD,grid:ED,overlayPriceScales:{...OD},leftPriceScale:{...OD,visible:!1},rightPriceScale:{...OD,visible:!0},defaultVisiblePriceScaleId:`right`,timeScale:kD,localization:{locale:JT?navigator.language:``,dateFormat:`dd MMM 'yy`},handleScroll:{mouseWheel:!0,pressedMouseMove:!0,horzTouchDrag:!0,vertTouchDrag:!0},handleScale:{axisPressedMouseMove:{time:!0,price:!0},axisDoubleClickReset:{time:!0,price:!0},mouseWheel:!0,pinch:!0},kineticScroll:{mouse:!1,touch:!0},trackingMode:{exitMode:1}}}var jD=class{constructor(e,t,n){this.hv=e,this.Ug=t,this.$g=n??0}applyOptions(e){this.hv.Qt().Dd(this.Ug,e,this.$g)}options(){return this.Ki().N()}width(){return NC(this.Ug)?this.hv.DM(this.Ug):0}setVisibleRange(e){this.setAutoScale(!1),this.Ki().Go(new ew(e.from,e.to))}getVisibleRange(){let e,t,n=this.Ki().ar();if(n===null)return null;if(this.Ki().ho()){let r=this.Ki().S_(),i=kT(r);n=Qw(n,this.Ki().lo()),e=Number((Math.round(n.Je()/r)*r).toFixed(i)),t=Number((Math.round(n.Qe()/r)*r).toFixed(i))}else e=n.Je(),t=n.Qe();return{from:e,to:t}}setAutoScale(e){this.applyOptions({autoScale:e})}Ki(){return $(this.hv.Qt().Id(this.Ug,this.$g)).Ft}},MD=class{constructor(e,t,n,r){this.hv=e,this.yt=n,this.jg=t,this.qg=r}getHeight(){return this.yt.$t()}setHeight(e){let t=this.hv.Qt(),n=t._f(this.yt);t.Ld(n,e)}getStretchFactor(){return this.yt.F_()}setStretchFactor(e){this.yt.W_(e),this.hv.Qt().ka()}paneIndex(){return this.hv.Qt()._f(this.yt)}moveTo(e){let t=this.paneIndex();t!==e&&(qS(e>=0&&e<this.hv.lv().length,`Invalid pane index`),this.hv.Qt().Od(t,e))}getSeries(){return this.yt.Y_().map((e=>this.jg(e)))??[]}getHTMLElement(){let e=this.hv.lv();return e&&e.length!==0&&e[this.paneIndex()]?e[this.paneIndex()].fv():null}attachPrimitive(e){this.yt.ol(e),e.attached&&e.attached({chart:this.qg,requestUpdate:()=>this.yt.Qt().ka()})}detachPrimitive(e){this.yt._l(e)}priceScale(e){if(this.yt.O_(e)===null)throw Error(`Cannot find price scale with id: ${e}`);return new jD(this.hv,e,this.paneIndex())}setPreserveEmptyPane(e){this.yt.j_(e)}preserveEmptyPane(){return this.yt.q_()}addCustomSeries(e,t={},n=0){return this.qg.addCustomSeries(e,t,n)}addSeries(e,t={}){return this.qg.addSeries(e,t,this.paneIndex())}},ND={color:`#FF0000`,price:0,lineStyle:2,lineWidth:1,lineVisible:!0,axisLabelVisible:!0,title:``,axisLabelColor:``,axisLabelTextColor:``},PD=class{constructor(e){this._r=e}applyOptions(e){this._r.vr(e)}options(){return this._r.N()}Yg(){return this._r}},FD=class{constructor(e,t,n,r,i,a){this.Kg=new XS,this.ae=e,this.Gg=t,this.Zg=n,this.Pu=i,this.qg=r,this.Xg=a}m(){this.Kg.m()}priceFormatter(){return this.ae.sl()}priceToCoordinate(e){let t=this.ae.Lt();return t===null?null:this.ae.Ft().Nt(e,t.Wt)}coordinateToPrice(e){let t=this.ae.Lt();return t===null?null:this.ae.Ft().Tn(e,t.Wt)}barsInLogicalRange(e){if(e===null)return null;let t=new bT(new _T(e.from,e.to)).Uu(),n=this.ae.Un();if(n.Zi())return null;let r=n.Hn(t.Na(),1),i=n.Hn(t.bi(),-1),a=$(n.Rh()),o=$(n.Qn());if(r!==null&&i!==null&&r.$n>i.$n)return{barsBefore:e.from-a,barsAfter:o-e.to};let s={barsBefore:r===null||r.$n===a?e.from-a:r.$n-a,barsAfter:i===null||i.$n===o?o-e.to:o-i.$n};return r!==null&&i!==null&&(s.from=r.Qr,s.to=i.Qr),s}setData(e){this.Pu,this.ae.bh(),this.Gg.Jg(this.ae,e),this.Qg(`full`)}update(e,t=!1){this.ae.bh(),this.Gg.tb(this.ae,e,t),this.Qg(`update`)}pop(e=1){let t=this.Gg.ib(this.ae,e);t.length!==0&&this.Qg(`update`);let n=CD(this.seriesType());return t.map((e=>n(e)))}dataByIndex(e,t){let n=this.ae.Un().Hn(e,t);return n===null?null:CD(this.seriesType())(n)}data(){let e=CD(this.seriesType());return this.ae.Un().Bh().map((t=>e(t)))}subscribeDataChanged(e){this.Kg.i(e)}unsubscribeDataChanged(e){this.Kg._(e)}applyOptions(e){this.ae.vr(e)}options(){return nC(this.ae.N())}priceScale(){return this.Zg.priceScale(this.ae.Ft().pl(),this.getPane().paneIndex())}createPriceLine(e){let t=ZS(nC(ND),e);return new PD(this.ae.Ea(t))}removePriceLine(e){this.ae.Aa(e.Yg())}priceLines(){return this.ae.La().map((e=>new PD(e)))}seriesType(){return this.ae.bh()}lastValueData(e){let t=this.ae.Ae(e);return t.Le?{noData:!0}:{noData:!1,price:t.Mt,color:t.R}}attachPrimitive(e){this.ae.ol(e),e.attached&&e.attached({chart:this.qg,series:this,requestUpdate:()=>this.ae.Qt().ka(),horzScaleBehavior:this.Pu})}detachPrimitive(e){this.ae._l(e),e.detached&&e.detached(),this.ae.Qt().ka()}getPane(){let e=this.ae,t=$(this.ae.Qt().Ks(e));return this.Xg(t)}moveToPane(e){this.ae.Qt().rf(this.ae,e)}seriesOrder(){let e=this.ae.Qt().Ks(this.ae);return e===null?-1:e.Y_().indexOf(this.ae)}setSeriesOrder(e){let t=this.ae.Qt().Ks(this.ae);t!==null&&t.vu(this.ae,e)}Qg(e){this.Kg.v()&&this.Kg.p(e)}},ID=class{constructor(e,t,n){this.nb=new XS,this.Qu=new XS,this.Nw=new XS,this.sn=e,this.ia=e.Et(),this.vM=t,this.ia.Zc().i(this.sb.bind(this)),this.ia.Xc().i(this.eb.bind(this)),this.vM.qw().i(this.rb.bind(this)),this.Pu=n}m(){this.ia.Zc().u(this),this.ia.Xc().u(this),this.vM.qw().u(this),this.nb.m(),this.Qu.m(),this.Nw.m()}scrollPosition(){return this.ia.Oc()}scrollToPosition(e,t){t?this.ia.Yc(e,1e3):this.sn.gs(e)}scrollToRealTime(){this.ia.qc()}getVisibleRange(){let e=this.ia.xc();return e===null?null:{from:e.from.originalTime,to:e.to.originalTime}}setVisibleRange(e){let t={from:this.Pu.convertHorzItemToInternal(e.from),to:this.Pu.convertHorzItemToInternal(e.to)},n=this.ia.kc(t);this.sn.sf(n)}getVisibleLogicalRange(){let e=this.ia.Sc();return e===null?null:{from:e.Na(),to:e.bi()}}setVisibleLogicalRange(e){qS(e.from<=e.to,`The from index cannot be after the to index.`),this.sn.sf(e)}resetTimeScale(){this.sn.ws()}fitContent(){this.sn.td()}logicalToCoordinate(e){let t=this.sn.Et();return t.Zi()?null:t.jt(e)}coordinateToLogical(e){return this.ia.Zi()?null:this.ia.Vc(e)}timeToIndex(e,t){let n=this.Pu.convertHorzItemToInternal(e);return this.ia.Mc(n,t)}timeToCoordinate(e){let t=this.timeToIndex(e,!1);return t===null?null:this.ia.jt(t)}coordinateToTime(e){let t=this.sn.Et(),n=t.Vc(e),r=t.en(n);return r===null?null:r.originalTime}width(){return this.vM.pv().width}height(){return this.vM.pv().height}subscribeVisibleTimeRangeChange(e){this.nb.i(e)}unsubscribeVisibleTimeRangeChange(e){this.nb._(e)}subscribeVisibleLogicalRangeChange(e){this.Qu.i(e)}unsubscribeVisibleLogicalRangeChange(e){this.Qu._(e)}subscribeSizeChange(e){this.Nw.i(e)}unsubscribeSizeChange(e){this.Nw._(e)}applyOptions(e){this.ia.vr(e)}options(){return{...nC(this.ia.N()),barSpacing:this.ia.ml()}}sb(){this.nb.v()&&this.nb.p(this.getVisibleRange())}eb(){this.Qu.v()&&this.Qu.p(this.getVisibleLogicalRange())}rb(e){this.Nw.p(e.width,e.height)}};function LD(e){return function(e){if(tC(e.handleScale)){let t=e.handleScale;e.handleScale={axisDoubleClickReset:{time:t,price:t},axisPressedMouseMove:{time:t,price:t},mouseWheel:t,pinch:t}}else if(e.handleScale!==void 0){let{axisPressedMouseMove:t,axisDoubleClickReset:n}=e.handleScale;tC(t)&&(e.handleScale.axisPressedMouseMove={time:t,price:t}),tC(n)&&(e.handleScale.axisDoubleClickReset={time:n,price:n})}let t=e.handleScroll;tC(t)&&(e.handleScroll={horzTouchDrag:t,vertTouchDrag:t,mouseWheel:t,pressedMouseMove:t})}(e),e}var RD=class{constructor(e,t,n){this.hb=new Map,this.ab=new Map,this.lb=new XS,this.ob=new XS,this._b=new XS,this.dd=new WeakMap,this.ub=new YE(t);let r=n===void 0?nC(AD()):ZS(nC(AD()),LD(n));this.cb=t,this.hv=new ME(e,r,t),this.hv.mw().i((e=>{this.lb.v()&&this.lb.p(this.fb(e()))}),this),this.hv.ww().i((e=>{this.ob.v()&&this.ob.p(this.fb(e()))}),this),this.hv.Bd().i((e=>{this._b.v()&&this._b.p(this.fb(e()))}),this);let i=this.hv.Qt();this.pb=new ID(i,this.hv.bM(),this.cb)}remove(){this.hv.mw().u(this),this.hv.ww().u(this),this.hv.Bd().u(this),this.pb.m(),this.hv.m(),this.hb.clear(),this.ab.clear(),this.lb.m(),this.ob.m(),this._b.m(),this.ub.m()}resize(e,t,n){this.autoSizeActive()||this.hv.wM(e,t,n)}addCustomSeries(e,t={},n=0){let r=(e=>({type:`Custom`,isBuiltIn:!1,defaultOptions:{...mD,...e.defaultOptions()},mb:hD,wb:e}))(YS(e));return this.Mb(r,t,n)}addSeries(e,t={},n=0){return this.Mb(e,t,n)}removeSeries(e){let t=JS(this.hb.get(e)),n=this.ub.if(t);this.hv.Qt().if(t),this.gb(n),this.hb.delete(e),this.ab.delete(t)}Jg(e,t){this.gb(this.ub.og(e,t))}tb(e,t,n){this.gb(this.ub.pg(e,t,n))}ib(e,t){let[n,r]=this.ub.wg(e,t);return n.length!==0&&this.gb(r),n}subscribeClick(e){this.lb.i(e)}unsubscribeClick(e){this.lb._(e)}subscribeCrosshairMove(e){this._b.i(e)}unsubscribeCrosshairMove(e){this._b._(e)}subscribeDblClick(e){this.ob.i(e)}unsubscribeDblClick(e){this.ob._(e)}priceScale(e,t=0){return new jD(this.hv,e,t)}timeScale(){return this.pb}applyOptions(e){this.hv.vr(LD(e))}options(){return this.hv.N()}takeScreenshot(e=!1,t=!1){let n,r;try{t||(n=this.hv.Qt().N().crosshair.mode,this.hv.vr({crosshair:{mode:2}})),r=this.hv.TM(e)}finally{t||n===void 0||this.hv.Qt().vr({crosshair:{mode:n}})}return r}addPane(e=!1){let t=this.hv.Qt().uf();return t.j_(e),this.bb(t)}removePane(e){this.hv.Qt().Ad(e)}swapPanes(e,t){this.hv.Qt().zd(e,t)}autoSizeActive(){return this.hv.CM()}chartElement(){return this.hv.Mv()}panes(){return this.hv.Qt().Gn().map((e=>this.bb(e)))}paneSize(e=0){let t=this.hv.AM(e);return{height:t.height,width:t.width}}setCrosshairPosition(e,t,n){let r=this.hb.get(n);if(r===void 0)return;let i=this.hv.Qt().Ks(r);i!==null&&this.hv.Qt().Gd(e,t,i)}clearCrosshairPosition(){this.hv.Qt().Zd(!0)}horzBehaviour(){return this.cb}Mb(e,t={},n=0){qS(e.mb!==void 0),function(e){if(e===void 0||e.type===`custom`)return;let t=e;t.minMove!==void 0&&t.precision===void 0&&(t.precision=kT(t.minMove))}(t.priceFormat),e.type===`Candlestick`&&function(e){e.borderColor!==void 0&&(e.borderUpColor=e.borderColor,e.borderDownColor=e.borderColor),e.wickColor!==void 0&&(e.wickUpColor=e.wickColor,e.wickDownColor=e.wickColor)}(t);let r=ZS(nC(HS),nC(e.defaultOptions),t),i=e.mb,a=new Fw(this.hv.Qt(),e.type,r,i,e.wb);this.hv.Qt().Qd(a,n);let o=new FD(a,this,this,this,this.cb,(e=>this.bb(e)));return this.hb.set(o,a),this.ab.set(a,o),o}gb(e){let t=this.hv.Qt();for(let t of e.Y_.keys())t.Ia();t.Xd(e.Et.Dc,e.Et.Sg,e.Et.xg),e.Y_.forEach(((e,t)=>t.ht(e.ue,e.bg))),t.Et().dc(),t.Lc()}Sb(e){return JS(this.ab.get(e))}xb(e){return e!==void 0&&this.ab.has(e)?this.Sb(e):void 0}fb(e){let t=new Map;e.QM.forEach(((e,n)=>{let r=n.bh(),i=CD(r)(e);if(r!==`Custom`)qS(FE(i));else{let e=n.cl();qS(!e||!1===e(i))}t.set(this.Sb(n),i)}));let n=this.xb(e.jM),r=e.YM===void 0?void 0:{type:e.YM.ds,sourceKind:e.YM.KM,objectKind:e.YM.GM,series:this.xb(e.YM.Y_),objectId:e.YM.ZM,paneIndex:e.YM.XM};return{time:e.Qr,logical:e.$n,point:e.JM,paneIndex:e.XM,hoveredInfo:r,hoveredSeries:n,hoveredObjectId:e.qM,seriesData:t,sourceEvent:e.tg}}bb(e){let t=this.dd.get(e);return t||(t=new MD(this.hv,(e=>this.Sb(e)),e,this),this.dd.set(e,t)),t}};function zD(e){if(eC(e)){let t=document.getElementById(e);return qS(t!==null,`Cannot find element in DOM with id=${e}`),t}return e}function BD(e,t,n){let r=new RD(zD(e),t,n);return t.setOptions(r.options()),r}function VD(e,t){return BD(e,new qT,qT.Tf(t))}var HD=class extends lD{constructor(e,t){super(e,t,!0)}Og(e,t,n){t.Ic(this.kg,iC(this.Tg)),e.Jo(this.kg,n,iC(this.Tg))}Tb(e,t){return{wt:e,Mt:t,_t:NaN,ut:NaN}}Lg(){let e=this.ae.Sa();this.kg=this.ae.Ua().Bh().map((t=>{let n;if((t.Gr??1)>1){let e=t.Wt[1],r=t.Wt[2],i=t.Wt[3];n=Math.abs(e-i)>Math.abs(r-i)?e:r}else n=t.Wt[3];return this.Rb(t.$n,n,e)}))}},UD=class extends lD{constructor(e,t){super(e,t,!1)}Bg(e,t){return aD(this.kg,this.Tg,e,t,this.le.Et().ml(),this.ae.N().hitTestTolerance,((e,t)=>{t[0]=e.n_,t[1]=e.s_}))}Og(e,t,n){t.Ic(this.kg,iC(this.Tg)),e.t_(this.kg,n,iC(this.Tg))}fS(e,t,n){return{wt:e,jr:t.Wt[0],qr:t.Wt[1],Yr:t.Wt[2],Kr:t.Wt[3],_t:NaN,i_:NaN,n_:NaN,s_:NaN,e_:NaN}}Lg(){let e=this.ae.Sa();this.kg=this.ae.Ua().Bh().map((t=>this.Rb(t.$n,t,e)))}},WD=class extends fC{constructor(){super(...arguments),this.qt=null,this.oS=0}ht(e){this.qt=e}et(e){if(this.qt===null||this.qt.Un.length===0||this.qt.lt===null)return;let{horizontalPixelRatio:t}=e;this.oS=function(e,t){if(e>=2.5&&e<=4)return Math.floor(3*t);let n=1-.2*Math.atan(Math.max(4,e)-4)/(.5*Math.PI),r=Math.floor(e*n*t),i=Math.floor(e*t);return Math.max(Math.floor(t),Math.min(r,i))}(this.qt.ml,t),this.oS>=2&&Math.floor(t)%2!=this.oS%2&&this.oS--;let n=this.qt.Un;this.qt.pS&&this.vS(e,n,this.qt.lt),this.qt.gi&&this.Vm(e,n,this.qt.lt);let r=this.mS(t);(!this.qt.gi||this.oS>2*r)&&this.wS(e,n,this.qt.lt)}vS(e,t,n){if(this.qt===null)return;let{context:r,horizontalPixelRatio:i,verticalPixelRatio:a}=e,o=``,s=Math.min(Math.floor(i),Math.floor(this.qt.ml*i));s=Math.max(Math.floor(i),Math.min(s,this.oS));let c=Math.floor(.5*s),l=null;for(let e=n.from;e<n.to;e++){let n=t[e];n.rh!==o&&(r.fillStyle=n.rh,o=n.rh);let u=Math.round(Math.min(n.i_,n.e_)*a),d=Math.round(Math.max(n.i_,n.e_)*a),f=Math.round(n.n_*a),p=Math.round(n.s_*a),m=Math.round(i*n._t)-c,h=m+s-1;l!==null&&(m=Math.max(l+1,m),m=Math.min(m,h));let g=h-m+1;r.fillRect(m,f,g,u-f),r.fillRect(m,d+1,g,p-d),l=h}}mS(e){let t=Math.floor(1*e);this.oS<=2*t&&(t=Math.floor(.5*(this.oS-1)));let n=Math.max(Math.floor(e),t);return this.oS<=2*n?Math.max(Math.floor(e),Math.floor(1*e)):n}Vm(e,t,n){if(this.qt===null)return;let{context:r,horizontalPixelRatio:i,verticalPixelRatio:a}=e,o=``,s=this.mS(i),c=null;for(let e=n.from;e<n.to;e++){let n=t[e];n.eh!==o&&(r.fillStyle=n.eh,o=n.eh);let l=Math.round(n._t*i)-Math.floor(.5*this.oS),u=l+this.oS-1,d=Math.round(Math.min(n.i_,n.e_)*a),f=Math.round(Math.max(n.i_,n.e_)*a);if(c!==null&&(l=Math.max(c+1,l),l=Math.min(l,u)),this.qt.ml*i>2*s)yC(r,l,d,u-l+1,f-d+1,s);else{let e=u-l+1;r.fillRect(l,d,e,f-d+1)}c=u}}wS(e,t,n){if(this.qt===null)return;let{context:r,horizontalPixelRatio:i,verticalPixelRatio:a}=e,o=``,s=this.mS(i);for(let e=n.from;e<n.to;e++){let n=t[e],c=Math.round(Math.min(n.i_,n.e_)*a),l=Math.round(Math.max(n.i_,n.e_)*a),u=Math.round(n._t*i)-Math.floor(.5*this.oS),d=u+this.oS-1;if(n.sh!==o){let e=n.sh;r.fillStyle=e,o=e}this.qt.gi&&(u+=s,c+=s,d-=s,l-=s),c>l||r.fillRect(u,c,d-u+1,l-c+1)}}},GD=class extends UD{constructor(){super(...arguments),this.Vg=new WD}Rb(e,t,n){return{...this.fS(e,t,n),...n.Sh(e)}}Ng(){let e=this.ae.N();this.Vg.ht({Un:this.kg,ml:this.le.Et().ml(),pS:e.wickVisible,gi:e.borderVisible,lt:this.Tg})}},KD={type:`Candlestick`,isBuiltIn:!0,defaultOptions:{upColor:`#26a69a`,downColor:`#ef5350`,wickVisible:!0,borderVisible:!0,borderColor:`#378658`,borderUpColor:`#26a69a`,borderDownColor:`#ef5350`,wickColor:`#737375`,wickUpColor:`#26a69a`,wickDownColor:`#ef5350`},mb:(e,t)=>new GD(e,t)},qD=class extends fC{constructor(){super(...arguments),this.qt=null,this.MS=[]}ht(e){this.qt=e,this.MS=[]}et({context:e,horizontalPixelRatio:t,verticalPixelRatio:n}){if(this.qt===null||this.qt.ot.length===0||this.qt.lt===null)return;this.MS.length||this.gS(t);let r=Math.max(1,Math.floor(n)),i=Math.round(this.qt.bS*n)-Math.floor(r/2),a=i+r;for(let t=this.qt.lt.from;t<this.qt.lt.to;t++){let o=this.qt.ot[t],s=this.MS[t-this.qt.lt.from],c=Math.round(o.ut*n),l,u;e.fillStyle=o.sh,c<=i?(l=c,u=a):(l=i,u=c-Math.floor(r/2)+r),e.fillRect(s.Na,l,s.bi-s.Na+1,u-l)}}gS(e){if(this.qt===null||this.qt.ot.length===0||this.qt.lt===null)return void(this.MS=[]);let t=Math.ceil(this.qt.ml*e)<=1?0:Math.max(1,Math.floor(e)),n=Math.round(this.qt.ml*e)-t;this.MS=Array(this.qt.lt.to-this.qt.lt.from);for(let t=this.qt.lt.from;t<this.qt.lt.to;t++){let r=this.qt.ot[t],i=Math.round(r._t*e),a,o;if(n%2){let e=(n-1)/2;a=i-e,o=i+e}else{let e=n/2;a=i-e,o=i+e-1}this.MS[t-this.qt.lt.from]={Na:a,bi:o,SS:i,ce:r._t*e,wt:r.wt}}for(let e=this.qt.lt.from+1;e<this.qt.lt.to;e++){let n=this.MS[e-this.qt.lt.from],r=this.MS[e-this.qt.lt.from-1];n.wt===r.wt+1&&n.Na-r.bi!==t+1&&(r.SS>r.ce?r.bi=n.Na-t-1:n.Na=r.bi+t+1)}let r=Math.ceil(this.qt.ml*e);for(let e=this.qt.lt.from;e<this.qt.lt.to;e++){let t=this.MS[e-this.qt.lt.from];t.bi<t.Na&&(t.bi=t.Na);let n=t.bi-t.Na+1;r=Math.min(n,r)}if(t>0&&r<4)for(let e=this.qt.lt.from;e<this.qt.lt.to;e++){let t=this.MS[e-this.qt.lt.from];t.bi-t.Na+1>r&&(t.SS>t.ce?--t.bi:t.Na+=1)}}},JD=class extends HD{constructor(){super(...arguments),this.Vg=new qD}Bg(e,t){let n=this.ae.Ft().Nt(this.ae.N().base,$(this.ae.Lt()).Wt);return n===null?null:aD(this.kg,this.Tg,e,t,this.le.Et().ml(),this.ae.N().hitTestTolerance,((e,t)=>{t[0]=e.ut,t[1]=n}))}Rb(e,t,n){return{...this.Tb(e,t),...n.Sh(e)}}Ng(){let e={ot:this.kg,ml:this.le.Et().ml(),lt:this.Tg,bS:this.ae.Ft().Nt(this.ae.N().base,$(this.ae.Lt()).Wt)};this.Vg.ht(e)}},YD={type:`Histogram`,isBuiltIn:!0,defaultOptions:{color:`#26a69a`,base:0},mb:(e,t)=>new JD(e,t)};({...HS});var XD={account:{name:`Name`,address:`Account address`,balances:`Balances`,noBalances:`No token balances were returned.`,nfts:`NFTs`,noNfts:`No NFTs in the scanned objects.`,noImage:`No image`,objectsTruncated:`Some objects beyond the scanned range are omitted.`},receipt:{success:`Transaction succeeded on Sui`,failure:`Transaction failed on Sui`,sender:`Sender`,account:`Affected account`,object:`Object`,noBalanceChanges:`No balance changes were recorded.`,gasComputation:`Computation cost`,gasStorage:`Storage cost`,gasRebate:`Storage rebate`,gasBudget:`Network fee limit (gas budget)`,netFeeExplanation:`The network fee shown above includes the storage rebate. If it is negative, the rebate exceeds the computation and storage charges.`,estimatedNetFeeExplanation:`The estimated network fee shown above includes the storage rebate. If it is negative, the rebate exceeds the estimated computation and storage charges.`,gasLimitExplanation:`The gas budget limits network fee spending. It is not an estimate of the amount charged.`,gasPrice:`Gas price`,gasPayment:`Gas payment object`,graph:`Transaction graph`,graphTip:`A diagram of this transaction's programmable transaction block (PTB), derived from public on-chain data. It is a diagnostic view only, not transaction input, signing, or a safety verdict.`,graphReviewTip:`A diagram of the transaction prepared for this review and simulation. It shows what is being reviewed, not an actual result, permission to sign, or a guarantee of safety.`,graphRendering:`Rendering the transaction graph…`,graphFailed:`The transaction graph could not be rendered`,graphZoomIn:`Zoom in`,graphZoomOut:`Zoom out`,graphCenter:`Center`,graphShowAddresses:`Show full addresses`,graphShowNames:`Show readable labels`,moveCalls:`Move calls`,noMoveCalls:`No Move calls were recorded.`,inputs:`Inputs`,noInputs:`No inputs were recorded.`,inputKinds:{object:`Owned object`,shared_object:`Shared object`,receiving:`Receiving object`,pure:`Pure value`,withdrawal:`Balance withdrawal`,unknown:`Input`},bytes:`bytes`,events:`Events`,noEvents:`No events were recorded.`,objectChanges:`Object changes`,noObjectChanges:`No object changes were recorded.`},chart:{boundaryUsdc:`Prices are in USDC, not USD; dollar parity is not guaranteed.`,boundaryScope:`Historical prices, not live quotes.`,source:`Source: DeepBookV3 Indexer.`,renderedWith:`Rendered with`,library:`TradingView Lightweight Charts`},common:{walletStatusRecovery:`Ask in chat to open Settings, then use Troubleshooting to restart the connection service. This does not confirm removal of a connection in your wallet app.`,mainnet:`Sui mainnet`,retrievedAt:`Data retrieved`}},ZD={en:XD};function QD(){try{return(navigator.language||`en`).slice(0,2).toLowerCase()}catch{return`en`}}function $D(e=QD()){return ZD[e]??XD}var eO=$D(),tO={source_unavailable:`Chart data is unavailable right now.`,source_timeout:`The chart data source did not respond in time.`,source_http_error:`The chart data source returned an error.`,official_indexer_invalid_payload:`The chart data source returned information that could not be used.`,missing_pool_name:`No trading pair was selected.`,unsupported_interval:`This candle interval is not supported.`,invalid_timestamp:`A start or end time could not be read.`,invalid_timestamp_window:`The start time must be before the end time.`,invalid_limit:`The requested number of candles is not valid.`,unsupported_query_field:`This chart request includes an unsupported option.`,duplicate_query_field:`This chart request repeats an option.`,limit_exceeds_chart_cap:`This chart request exceeds the candle limit.`,pool_not_in_official_usdc_pools:`This trading pair is not available in the supported USDC charts.`},nO=B({start:F(),timestampMs:I().int(),open:F(),high:F(),low:F(),close:F(),volume:F()}),rO=[`Latest 500`,`Last 24h`,`Last 7d`,`Last 30d`],iO=B({status:G(`ok`),pools:z(B({poolName:F(),baseAsset:B({symbol:F()})})),intervals:z(F()),defaultInterval:F(),defaultLimit:I().int().positive(),maxCandles:I().int().positive()}),aO=B({status:W([`ok`,`empty_result`]),candles:z(nO),candleCount:I().int().nonnegative(),query:B({poolName:F(),interval:F(),startTimeMs:I().int().nonnegative().optional(),endTimeMs:I().int().nonnegative().optional(),limit:I().int().positive()}),source:B({fetchedAt:F()}),pair:B({baseAsset:B({symbol:F()}),quoteAsset:B({symbol:G(`USDC`)})})}).refine(e=>e.candleCount===e.candles.length,`Candle count differs from returned rows.`),oO={title:`DeepBook USDC chart`,guidance:(e,t)=>t.recoveryNeeded?`Ask in chat for a new chart with the pair and time range you want.`:void 0,controls(e,t){let n=iO.parse(e.data),r=document.createElement(`form`);r.className=`ui-form`;let i=ig({choices:[{label:`Choose a pair`,value:``},...n.pools.map(e=>({label:`${e.baseAsset.symbol} / USDC`,value:e.poolName}))]});i.required=!0;let a=ig({choices:n.intervals.map(e=>({label:e,value:e}))});a.value=typeof e.input.interval==`string`?e.input.interval:n.defaultInterval;let o=ng({placeholder:`YYYY-MM-DDTHH:mm`}),s=ng({placeholder:`YYYY-MM-DDTHH:mm`});typeof e.input.startTimeMs==`number`&&(o.value=dO(e.input.startTimeMs)),typeof e.input.endTimeMs==`number`&&(s.value=dO(e.input.endTimeMs));let c=Number(e.input.limit??n.defaultLimit),l=ag(`Time range & interval`,e.input.startTimeMs!==void 0||e.input.endTimeMs!==void 0),u=$h(`p`,`ui-note`,cO(e.input));for(let e of[o,s])e.addEventListener(`input`,()=>{u.textContent=`Custom range · UTC`});let d=$h(`div`,`card-actions`);for(let e of rO){let t=eg(e===`Latest 500`?`Recent`:e,()=>{let t=lO(e,new Date);o.value=t.startInput,s.value=t.endInput,c=Number(t.limitInput),u.textContent=e===`Latest 500`?`Recent candles · UTC`:`${e} · UTC`,p()},`secondary`);d.append(t)}let f=$h(`p`,`ui-error`);f.setAttribute(`role`,`alert`),l.body.append(rg(`Candle interval`,a),d,u,rg(`Start (UTC)`,o),rg(`End (UTC)`,s)),r.append($h(`p`,`ui-note`,`Set the time range and interval before choosing a pair, if needed.`),rg(`Choose a pair to open the chart`,i),l.details,f);function p(){if(i.value)try{let e=uO(o.value),n=uO(s.value);if(e!==void 0&&n!==void 0&&e>=n)throw Error(`Start must precede end.`);t({poolName:i.value,interval:a.value,limit:c,...e===void 0?{}:{startTimeMs:e},...n===void 0?{}:{endTimeMs:n}})}catch(e){f.textContent=e instanceof Error?e.message:`Invalid chart input.`}}r.addEventListener(`submit`,e=>{e.preventDefault(),p()});for(let e of[i,a,o,s])e.addEventListener(`change`,p);return{node:r,selectionRecovery:{label:`Retry chart`,retry:p}}},result(e){let t=aO.safeParse(e.data);if(!t.success){let t=e.data;if(t?.status===`source_unavailable`||t?.status===`unsupported_input`||t?.status===`unsupported_pool`||t?.status===`over_limit`){let e=typeof t.reason==`string`?t.reason:t.status,n=Object.hasOwn(tO,e)?tO[e]:`The requested chart could not be loaded.`,r=$h(`div`);r.append($h(`p`,`ui-note`,n),$h(`p`,`ui-note`,`Ask in chat for a new chart with the pair and time range you want.`));let i=ag(`Details`);return i.body.append($h(`p`,void 0,`Reported reason: ${e}`)),r.append(i.details),{node:r}}throw Error(`Chart data is incomplete.`)}let n=t.data,r=$h(`div`);r.append($h(`p`,`ui-note`,`${n.pair.baseAsset.symbol} / USDC · ${n.query.interval}`),$h(`p`,`ui-note`,cO(n.query)));let i=ag(`Details`),a=$h(`p`,`ui-note`,`${eO.common.retrievedAt}: `);a.append(og(n.source.fetchedAt)),i.body.append(a);let o=e=>e===void 0?`not specified`:Number.isFinite(new Date(e).getTime())?new Date(e).toISOString():Qh(e);i.body.append($h(`p`,void 0,`Start: ${o(n.query.startTimeMs)} · End: ${o(n.query.endTimeMs)}`)),n.candleCount>=n.query.limit&&r.append($h(`p`,`ui-note`,`This view is limited to ${n.query.limit} candles; the requested period may contain more.`));let s=$h(`p`,`ui-note`,`${eO.chart.boundaryUsdc} ${eO.chart.boundaryScope} ${eO.chart.source}`),c=tg(eO.chart.library,`https://www.tradingview.com/`);if(c.target=`_blank`,c.rel=`noopener noreferrer`,s.append(` ${eO.chart.renderedWith} `,c,`.`),n.candles.length===0)return i.body.append(s),r.append($h(`p`,`ui-note`,`No candles returned for this range.`),i.details),{node:r};let l=$h(`div`,`card-chart`),u=$h(`p`,`ui-note`),d=n.candles.at(-1),f=e=>`${Qh(e.start)} · Open ${e.open} · High ${e.high} · Low ${e.low} · Close ${e.close} · Volume ${e.volume}`;u.textContent=f(d),i.body.append(u,s),r.append(l,i.details);let p,m,h,g,_=!1,v=!1,y=0,b=0,ee=()=>{let e=getComputedStyle(document.documentElement),t=t=>e.getPropertyValue(t).trim();p?.applyOptions({layout:{background:{color:t(`--ui-surface`)},textColor:t(`--ui-text`)},grid:{vertLines:{color:t(`--ui-border`)},horzLines:{color:t(`--ui-border`)}}})},x=()=>{v||(v=!0,m?.disconnect(),h?.disconnect(),p?.remove(),g!==void 0&&cancelAnimationFrame(g))},te=()=>{if(v||!l.isConnected)return;let e=l.clientWidth,t=l.clientHeight;if(!(e<=0||t<=0||e===y&&t===b))try{if(p)p.resize(e,t);else{p=VD(l,{width:e,height:t,autoSize:!1,layout:{attributionLogo:!1},timeScale:{timeVisible:!0,secondsVisible:!1,minBarSpacing:0,lockVisibleTimeRangeOnResize:!0}});let r=p.addSeries(KD,{upColor:`#167752`,downColor:`#b44336`,borderVisible:!1,wickUpColor:`#167752`,wickDownColor:`#b44336`,priceFormat:{type:`price`,precision:6,minMove:1e-6}}),i=p.addSeries(YD,{priceFormat:{type:`volume`},priceScaleId:``},1),a=sO(n.candles,n.query);r.setData(a.prices),i.setData(a.volumes),p.panes()[0]?.setStretchFactor(3),p.panes()[1]?.setStretchFactor(1),a.range?p.timeScale().setVisibleRange(a.range):p.timeScale().fitContent();let o=new Map(n.candles.map(e=>[mO(e),e]));p.subscribeCrosshairMove(e=>{u.textContent=f((typeof e.time==`number`?o.get(e.time):void 0)??d)}),ee(),h=new MutationObserver(ee),h.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]})}y=e,b=t}catch{x(),l.replaceChildren($h(`p`,`ui-error`,`The chart could not be displayed. The saved query and source data are unchanged.`))}};return{node:r,mount:()=>{_||v||(_=!0,m=new ResizeObserver(()=>{v||g!==void 0||(g=requestAnimationFrame(()=>{g=void 0,te()}))}),m.observe(l),te())},dispose:x}}};function sO(e,t){let n=e.map(fO),r=e.map(pO),i=new Set(n.map(e=>e.time));for(let e of[t.startTimeMs,t.endTimeMs]){if(e===void 0)continue;let t=e/1e3;i.has(t)||(n.push({time:t}),r.push({time:t}),i.add(t))}n.sort((e,t)=>e.time-t.time),r.sort((e,t)=>e.time-t.time);let a=t.startTimeMs===void 0?n[0]?.time:t.startTimeMs/1e3,o=t.endTimeMs===void 0?n.at(-1)?.time:t.endTimeMs/1e3;return{prices:n,volumes:r,range:(t.startTimeMs!==void 0||t.endTimeMs!==void 0)&&a!==void 0&&o!==void 0&&a<o?{from:a,to:o}:void 0}}function cO(e){if(e.startTimeMs===void 0&&e.endTimeMs===void 0)return`Recent candles · UTC`;let t=e=>{if(e===void 0)return`not specified`;let t=new Date(e);return Number.isNaN(t.getTime())?`${e} milliseconds since 1970-01-01T00:00:00Z`:Qh(e)};return`Range (UTC): ${t(e.startTimeMs)} → ${t(e.endTimeMs)}`}function lO(e,t){if(e===`Latest 500`)return{startInput:``,endInput:``,limitInput:`500`};let n=e===`Last 24h`?864e5:e===`Last 7d`?6048e5:2592e6,r=t.getTime();return{startInput:dO(r-n),endInput:dO(r),limitInput:`10000`}}function uO(e){let t=e.trim();if(t===``)return;if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/.test(t))throw Error(`UTC timestamps must use YYYY-MM-DDTHH:mm.`);let n=Date.parse(`${t}:00.000Z`);if(!Number.isSafeInteger(n))throw Error(`UTC timestamp is invalid.`);return n}function dO(e){return new Date(e).toISOString().slice(0,16)}function fO(e){return{time:mO(e),open:Number(e.open),high:Number(e.high),low:Number(e.low),close:Number(e.close)}}function pO(e){return{time:mO(e),value:Number(e.volume),color:Number(e.close)>=Number(e.open)?`rgba(22, 119, 82, 0.45)`:`rgba(180, 67, 54, 0.45)`}}function mO(e){return Math.floor(e.timestampMs/1e3)}jS(`chart`,oO);</script></body></html>